Skip to content
Prev 169906 / 398506 Next

Odp: Problem with retrieving updated variables after attach()

Berwin A Turlach wrote:
There is also

as.data.frame(as.list(pos.to.env(2)))

or ...as.environment("mat")

I wouldn't recommend using <<- like that though; the consequences of
spelling mistakes on the LHS are a bit scary. If you must, consider

with(pos.to.env(2),{
  id <- sample(100,5)
  age <- rnorm(5,mean=30)
})

or better, modify before attach, using within() or transform().