I have loaded in a R console different type of objects.
I can remove them all using
rm(list=ls())
or remove only the functions (but not the variables) using
rm(list=lsf.str())
My question is:
is there a way to remove all variables except the functions
Here’s a one-liner that removes all objects except for functions:
It uses
setdiffto find the subset of objects in the global environment (as returned byls()) that don’t have modefunction(as returned bylsf.str())