how to clear the environment in r code example Example 1: r remove all environment rm(list = ls()) Example 2: r clean environment rm(list = ls())