Re: [R] How to remove all objects except a few specified objects?

2010-08-25 Thread Cheng Peng
Thanks Josh and Karl. function dnrm() works well for my purpose. -- View this message in context: http://r.789695.n4.nabble.com/How-to-remove-all-objects-except-a-few-specified-objects-tp2335651p2337398.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] How to remove all objects except a few specified objects?

2010-08-25 Thread Cheng Peng
Thanks to De-Jian and Peter. Peter's way is neat and cool! -- View this message in context: http://r.789695.n4.nabble.com/How-to-remove-all-objects-except-a-few-specified-objects-tp2335651p2338221.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] How to remove all objects except a few specified objects?

2010-08-24 Thread 500600
a - 1 b - 2 c - 3 ls()[-a] # set minus to all the objects you want to retain rm(list = ls()[-a] # will remove all the objects - except a ls() # presto -- View this message in context:

Re: [R] How to remove all objects except a few specified objects?

2010-08-24 Thread Barry Rowlingson
2010/8/24 500600 romu...@gmail.com: a - 1 b - 2 c - 3 ls()[-a]  # set minus to all the objects you want to retain rm(list = ls()[-a]  # will remove all the objects - except a ls()  # presto Only because a=1 and a is the first item in the list! Not because you are doing '-a'! If a is 0

Re: [R] How to remove all objects except a few specified objects?

2010-08-24 Thread Nikhil Kaza
or use #not checked rm(setdiff(ls(),c(a, b)) On Aug 24, 2010, at 4:55 AM, Barry Rowlingson wrote: 2010/8/24 500600 romu...@gmail.com: a - 1 b - 2 c - 3 ls()[-a] # set minus to all the objects you want to retain rm(list = ls()[-a] # will remove all the objects - except a ls() # presto

Re: [R] How to remove all objects except a few specified objects?

2010-08-24 Thread Joshua Wiley
If you are going to be doing this a lot, you may want to consider making a little function. Here is an example 'do not remove' function. It defaults to the global environment, but you can always change it. Also, if you try to keep a variable name that does not exist, it will throw an error and

Re: [R] How to remove all objects except a few specified objects?

2010-08-24 Thread Cheng Peng
Thanks for all suggestions from Roman (?= 500600[via R]), Barry and Jim. It seems that ls()[-objectname] didn't work even on numeric matrices and user made functions. I will work with Jim's advice on using grep() and gc() to see whether it works. -- View this message in context:

Re: [R] How to remove all objects except a few specified objects?

2010-08-24 Thread Karl Brand
Hi Cheng, Check out the keep() function in package:gdata. And to be sure the removed objects are really removed from system memory i think you need to run gc(). hth, Karl On 8/23/2010 9:00 PM, Cheng Peng wrote: How to remove all R objects in the RAM except for a few specified ones?

Re: [R] How to remove all objects except a few specified objects?

2010-08-24 Thread Dejian Zhao
If your specified objects have a certain pattern, you can use the parameter pattern in ls() to remove or keep it. rm(list=ls(..., pattern=your_pattern)) If not, possibly you have to manually specify them. On 2010-8-24 3:00, Cheng Peng wrote: How to remove all R objects in the RAM except for a

Re: [R] How to remove all objects except a few specified objects?

2010-08-24 Thread Peter Alspach
ls(all=TRUE). HTH Peter Alspach -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Dejian Zhao Sent: Wednesday, 25 August 2010 1:32 p.m. To: r-help@r-project.org Subject: Re: [R] How to remove all objects except a few

[R] How to remove all objects except a few specified objects?

2010-08-23 Thread Cheng Peng
How to remove all R objects in the RAM except for a few specified ones? rm(list=ls()) removes all R objects in the R work space. Another question is that whether removing all R objects actually releases the RAM? Thanks. -- View this message in context: