[R] subsetting ls() as per class...

Jeff Newmiller jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Sat Jul 28 08:18:10 CEST 2018

You can extract the names into a character vector with ls and then use grep(..., values=TRUE ) to select which ones you want to remove, and then pass that list to rm.

However, due to the way R handles memory you are unlikely to see much savings by doing this. I would recommend focusing on creating a script or series of scripts that can allow you to re-create your analysis, and then restarting R whenever you are ready to reduce memory usage. This will have the side benefit of leaving you with a verified-complete record of how your analysis was done.

On July 27, 2018 10:58:36 PM PDT, akshay kulkarni <akshay_e4 using hotmail.com> wrote:
>dear memebers,
>I am using R in AWS linux instance for my research. I want to remove
>certain objects from the global environment  to reduce my EBS cost..for
>example, I want to remove all objects of class "xts", "zoo". Is there
>any way to automate this, instead of removing the objects one by one?
>Basically, I want to subset  ls() according to class, and then remove
>that subset by using rm function.
>I got to know about mget in SO, but that is not working in my case....
>Also, all the above objects end with ".NS".  I came to know that you
>can remove objects starting with a certain pattern; is there any way to
>remove objects ending in a certain pattern?
>very many thanks for your time and effort...
>yours sincerely,
>	[[alternative HTML version deleted]]
>R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.

Sent from my phone. Please excuse my brevity.

More information about the R-help mailing list