[R] variable scope

Sam Steingold sds at gnu.org
Tue Aug 28 20:29:21 CEST 2012


At the end of a for loop its variables are still present:

for (i in 1:10) {
  x <- vector(length=100000000)
}
ls()

will print "i" and "x".
this means that at the end of the for loop body I have to write

  rm(x)
  gc()

is there a more elegant way to handle this?

Thanks.

-- 
Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000
http://www.childpsy.net/ http://camera.org http://palestinefacts.org
http://iris.org.il http://www.PetitionOnline.com/tap12009/ http://truepeace.org
Computers are like air conditioners: they don't work with open windows!



More information about the R-help mailing list