#NOTE: ONLY RUN THIS IF YOU DON'T MIND ERASING YOUR R SESSION
a = 5
ls() ### a shows up
clear()
ls() ### nothing shows up
### create objects
a=1; b=2; c=3; d=4; e=5
### remove c
clear("c", keep=FALSE)
ls()
### remove all but a and b
clear(c("a", "b"), keep=TRUE)
ls()
Run the code above in your browser using DataLab