I would like to clean my R environment except for a data frame called "dd" and other data frames that start with "temp" (pattern). I've tried with different modifications of the code below but I cannot make it work. Any idea very much appreciated!
To remove everything except "dd":
rm(list=ls()[!ls() %in% c("dd")])
To remove everything containing "temp":
rm(list = ls(pattern = "temp"))
I want to keep in the environment "dd" and anything that starts with "temp".