[R] add columns to a data.frame

Christoph Lange clange at epost.de
Fri Apr 12 18:50:02 CEST 2002


(Reply to juan pablo perez)

> Dear R community:
> 
> it is possible to add a column wich results from an algebraic combination of 
> columns from a data frame to the same data frame?
> 
> e.g
> 
> I have a data frame like
> $X: num[1:10] 10,20,25,20...
> $Y: num[1:10] 152,458,698,587,...
> and I want to add a new column like
> $Z where Z=X+5*Y
> 
> what should I do?

Use

  cbind.data.frame



Christoph.
-- 
Christoph Lange                                    clange at epost.de
Verhaltensbiologie, FU Berlin                            838-55068
Haderslebener Str. 9, 12163 Berlin
http://www.verhaltensbiologie.fu-berlin.de/
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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 mailing list