How to clear the R environment

rm(list = ls(all.names = TRUE)) #will clear all objects includes hidden objects.
gc() #free up memrory and report the memory usage.

Kindly refer to What is the difference between gc() and rm().

3 Likes