[R] deleting variables

Rubén Roa-Ureta rroa at udec.cl
Tue Apr 29 18:09:25 CEST 2008


Richard Pearson wrote:
> ?rm
> 
> Richard
>

> Ralf Goertz wrote:
>> How can I automatically exclude one variable from being saved in the
>> workspace when I quit an R session? The problem is I don't know how to
>> erase a variable once it has been created.

[...]

>> Ralf

More on the use of rm. If you want to delete many variables in one go,

x<-runif(10)
y<-runif(10)
z<-runif(10)
ls() #you check all the objects in your workspace
#[1] "x" "y" "z"
rm(list=your.list <- ls()[2:3]) #you selected to delete all those 
objects whose indices are between 2 and 3.
rm("your.list") #remove the temporary list with variable names
ls()
[1] "x"

HTH
Rubén



More information about the R-help mailing list