Re: [R] Summing over specific columns in a matrix

2011-01-07 Thread Dennis Murphy
Hi: It's impolite on this list to hijack a thread to ask your own question. Please start a new thread in the future if you have a question of your own. Re your question, try this: Data1$Daily <- with(Data1, PL_Pos - Costs) Data1Sum <- aggregate(Daily ~ EnDate, FUN = sum) # Merge the two data fr

Re: [R] Summing over specific columns in a matrix

2011-01-07 Thread emj83
Thanks- this works just as I needed- Emma -- View this message in context: http://r.789695.n4.nabble.com/Summing-over-specific-columns-in-a-matrix-tp3179400p3179439.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org

Re: [R] Summing over specific columns in a matrix

2011-01-07 Thread Mark Knecht
On Fri, Jan 7, 2011 at 8:42 AM, Henrique Dallazuanna wrote: > Try this: > > rowSums(rowsum(t(m), rep(1:3, c(2, 2, 1)), na.rm = TRUE)) > > > On Fri, Jan 7, 2011 at 2:29 PM, emj83 wrote: > >> >> Hi, >> >> I would like to sum some specific columns in my matrix- for example, my >> matrix looks like t

Re: [R] Summing over specific columns in a matrix

2011-01-07 Thread Henrique Dallazuanna
Try this: rowSums(rowsum(t(m), rep(1:3, c(2, 2, 1)), na.rm = TRUE)) On Fri, Jan 7, 2011 at 2:29 PM, emj83 wrote: > > Hi, > > I would like to sum some specific columns in my matrix- for example, my > matrix looks like this: > [,1] [,2] [,3] [,4] [,5] > [1,]1 NA NA NA NA > [2,

[R] Summing over specific columns in a matrix

2011-01-07 Thread emj83
Hi, I would like to sum some specific columns in my matrix- for example, my matrix looks like this: [,1] [,2] [,3] [,4] [,5] [1,]1 NA NA NA NA [2,]21 NA1 NA [3,]321 21 [4,]432 32 [5,] NA NA NA43 [6,] NA