Removing objects from Environment using wildcard

Hi.

I have a lot of datasets and other objects in the environment. I want to delete the ones with the prefixes 'Sep' and 'Nov'.

I tried rm(sep*), but it shows an error:

Error: unexpected ')' in "rm(sep*)"

Please let me know if there is any way to solve this error.

Thank you.

Nile

You could try the following:

rm(list = ls()[substr(ls(),1,3) %in% c('Sep', 'Nov')])
1 Like

Thanks so much! It worked perfectly!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.