Re: [R] Removing objects and clearing memory

From: Jim Silverton <jim.silverton_at_gmail.com>
Date: Wed, 13 Apr 2011 11:12:41 -0400

Hey guys thanks very much for al your responses. It was very helpful.

Jim

On Tue, Apr 12, 2011 at 6:59 PM, Peter Ehlers <ehlers_at_ucalgary.ca> wrote:

> On 2011-04-12 15:52, Seeliger.Curt_at_epamail.epa.gov wrote:
>
>> How do I remove all objects except one in R?
>>>>>
>>>>> rm(list=ls()) #will remove ALL objects
>>>>
>>>
>>> But he wanted to remove all objects ***except one***!!! So what's the
>>> point of this answer?
>>>
>>> I can't see any way except a rather round-about kludge to do what the
>>> OP wants. ...
>>>
>>
>> That might work. Or try this, replacing QQQ with the name of the object
>> you want to keep.
>> rm(list=ls()[!grepl('^QQQ$',ls())])
>>
>> cur
>>
>
> package gdata has function keep() which does just what the OP asks for.
>
> Peter Ehlers
>
>

-- 
Thanks,
Jim.

	[[alternative HTML version deleted]]

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Wed 13 Apr 2011 - 15:15:18 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 13 Apr 2011 - 15:20:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive