[R] assign to data.frame
tlumley at u.washington.edu
Thu Jun 13 22:14:14 CEST 2002
On Thu, 13 Jun 2002, Michaell Taylor wrote:
> However, there are actually a number of such variables to be created. Sooo, I
> add.to.d2 <- names(d1)[!is.element(names(d1),names(d2)]
> for (V in add.to.d2)
> (ditto for the other data.frame)
> which gives me a d2$c in the global space, but not in the d2 dataframe. I see
> options for environment specification in assign, but can't seem to manage to
> specify a dataframe as the environ. Also tried: assign(as.name(paste('d2$',V,
> sep='')),rep(NA,10)) -- which wouldn't seem needed, and indeed, not.
> gotta be something I am missing and I am sure it is in the help files
> somewhere, but .... any hints?
You can't do this with assign(), which doesn't dispatch assignment
methods. In this case you can just
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
More information about the R-help