Re: [R] sum sections of data of different lengths from within a data frame

2010-02-10 Thread kMan
Original Message- From: Kara Przeczek [mailto:przec...@unbc.ca] Sent: Tuesday, February 09, 2010 7:07 PM To: r-help@r-project.org Subject: [R] sum sections of data of different lengths from within a data frame Dear R Help: I am trying to sum data from one column in a dataframe based on a

Re: [R] sum sections of data of different lengths from within a data frame

2010-02-09 Thread jim holtman
WIll this do it for you: > x <- read.table(textConnection("ColA ColB + 10 + 30 + 21 + 20 + 10 + 40 + 11 + 91 + 30 + 50 + 21"), header=TRUE) > closeAllConnections() > x.s <- split(x, cumsum(x$ColB)) > x.l <- do

[R] sum sections of data of different lengths from within a data frame

2010-02-09 Thread Kara Przeczek
Dear R Help: I am trying to sum data from one column in a dataframe based on a value in another. I do not know how to do this easily in R. For example: Col A Col B 10 30 21 20 10 40 11 91 30 50 21 I would l