Hello,

suppose I have a data frame:

> mat
 id age
1 NA  NA
2 NA  NA
3 NA  NA
4 NA  NA
5 NA  NA

Then I attach the data frame:

> attach(mat)

I assign some new values...

> id <<- sample(100,5)
> age <<- rnorm(5,mean=30)

Then I want to create a new data frame from the variables id and age which 
still are attached to position 2 of the R environment...

> new_mat <- data.frame(ls(pos=2)) # I want to rescue ALL variables that were 
> created by attach(mat)

> new_mat
 ls.pos...2.
1         age
2          id

But this leads to a bogus object... how can I rescue the updated id and age 
values into new_mat?


Regards,

David

-- 
Jetzt 1 Monat kostenlos! GMX FreeDSL - Telefonanschluss + DSL 
für nur 17,95 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a

______________________________________________
R-help@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.

Reply via email to