1

I know that I can delete all objects in this session with:

rm(list=ls())

Now I want to delete all objects in this session except that I have listed in a vector not_del.

How can I do it?

vasili111
  • 6,032
  • 10
  • 50
  • 80

1 Answers1

2

You can do the following:

rm(list=(setdiff(ls(),dont_remove)))
NelsonGon
  • 13,015
  • 7
  • 27
  • 57