[R] How to erase objects

Adaikalavan Ramasamy ramasamy at cancer.org.uk
Tue Sep 13 14:59:19 CEST 2005


You can also use ls() which is alias of objects().

One way is to remove unwanted objects by hand
 rm(a,b,c,d)

Another way is to save the required objects, remove everything and then
load the saved objects.
 save(x,y,z, file="out.rda", compress=TRUE)
 rm( list=ls() )
 load("out.rda")

The second approach allows you to load the objects in a fresh R session,
which is one way to release memory if gc() fails. But which approach you
prefer depends on the number of objects to be removed and saved.

Regards, Adai



On Tue, 2005-09-13 at 04:39 -0700, Martin Lam wrote:
> # to see the objects that are currently in memory
> objects()
> 
> # to remove everything
> rm(list = ls())
> 
> HTH,
> 
> Martin
> 
> --- Luis Ridao Cruz <Luisr at frs.fo> wrote:
> 
> > ?rm
> > 
> > 
> > >>> <v.schlecht at arcor.de> 13/09/2005 12:08:55 >>>
> > 
> > Hi, I admit that I rather carelessly built lots of
> > large objects and therefore ran out of memory. Most
> > objects, which I have at the moment are now
> > unnecessary, but it would take a lot of time to
> > recreate the last few ones from scratch. So I would
> > like to erase (get rid of) selected objects in order
> > to be able to continue. Does anyone know how I could
> > do this? 
> > 
> > Machen Sie aus 14 Cent spielend bis zu 100 Euro!
> > Die neue Gaming-Area von Arcor - Ã¼ber 50
> > Onlinespiele im Angebot.
> > http://www.arcor.de/rd/emf-gaming-1 
> > 
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help 
> > PLEASE do read the posting guide!
> > http://www.R-project.org/posting-guide.html
> > 
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
> > http://www.R-project.org/posting-guide.html
> >
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list