[R] Adding a new column to data frame (recoding)

Aleksey Naumov naumov at acsu.buffalo.edu
Tue Oct 10 20:03:15 CEST 2000

Dear R users,

I have a very simple question. What is the easiest way to recode data in
of the columns of a data frame and put it into a new column?

For example, here is a simple data frame:

1    1
2    2
3    3

How do I add a new column to data - 'var2' in which I group  values in
for example:

  var1 var2
1    1    4
2    2    4
3    3    5

It's got to be simple, but I can't find it...


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