I would like to remove some data from the workspace. I know the \"Clear All\" button will remove all data. However, I would like to remove just certain data.
For exa
A useful way to remove a whole set of named-alike objects:
rm(list = ls()[grep("^tmp", ls())])
thereby removing all objects whose name begins with the string "tmp".
Edit: Following Gsee's comment, making use of the pattern
argument:
rm(list = ls(pattern = "^tmp"))
Edit: Answering Rafael comment, one way to retain only a subset of objects is to name the data you want to retain with a specific pattern. For example if you wanted to remove all objects whose name do not start with paper
you would issue the following command:
rm(list = grep("^paper", ls(), value = TRUE, invert = TRUE))