I'm trying to remove all objects from my RStudio environment where the object names are NOT equal to a pattern.
rm(list=ls(pattern!="may19"))
However this gives me an error
Error in as.environment(pos) : no item called "pattern != "may19"" on the search list
Is there another way to approach this? Thanks in advance
We could use one of the following(other variants might exist, you can add all=TRUE or all.names=TRUE) for completeness:
rm(list=setdiff(ls(),"may19"))
rm(list=ls(pattern = "[^may19]"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With