[R] subtract 2 columns in a data.frame
Ko-Kang Kevin Wang
kwan022 at stat.auckland.ac.nz
Thu Sep 4 13:50:55 CEST 2003
On 4 Sep 2003, Ulrich Leopold wrote:
> 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.
Suppose your data frame is called foo, and you want the first column minus
the second:
foo[,1] - foo[,2]
--
Cheers,
Kevin
------------------------------------------------------------------------------
"On two occasions, I have been asked [by members of Parliament],
'Pray, Mr. Babbage, if you put into the machine wrong figures, will
the right answers come out?' I am not able to rightly apprehend the
kind of confusion of ideas that could provoke such a question."
-- Charles Babbage (1791-1871)
---- From Computer Stupidities: http://rinkworks.com/stupid/
--
Ko-Kang Kevin Wang
Master of Science (MSc) Student
SLC Tutor and Lab Demonstrator
Department of Statistics
University of Auckland
New Zealand
Homepage: http://www.stat.auckland.ac.nz/~kwan022
Ph: 373-7599
x88475 (City)
x88480 (Tamaki)
More information about the R-help
mailing list