[R] Recreate new dataframe based on condition

From: Sachin J <sachinj.2006_at_yahoo.com>
Date: Sat 15 Jul 2006 - 03:56:49 EST


Hi,    

  How can I achieve this in R. Dataset is as follows:    

>df

    x
1 2
2 4
3 1
4 3
5 3
6 2

  structure(list(x = c(2, 4, 1, 3, 3, 2)), .Names = "x", row.names = c("1", "2", "3", "4", "5", "6"), class = "data.frame")

  I want to recreate a new data frame whose rows are sum of (1&2, 3&4, 5&6) of original df. For example    

>newdf

     x
  1 6
  2 4
  3 5    

  Thanx in advance for the help.    

  Sachin                      


        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jul 15 04:02:53 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 15 Jul 2006 - 06:14:08 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.