[R] subtract 2 columns in a data.frame

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Thu Sep 4 13:20:42 CEST 2003


Ulrich Leopold <uleopold at science.uva.nl> writes:

> Dear list,
> 
> could someone point me to the right command to subtract 2 columns in a
> data.frame. Might be a bit embarrassing question. But I cannot figure
> out how to do this simple command in R.

E.g.,

mydata$difference <- mydata$x - mydata$y

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list