Re: [R] summing values for specific variables

2011-02-13 Thread Dennis Murphy
Hi: One (of many) ways is to use the aggregate() function in base R: df <- data.frame(g = rep(LETTERS[1:5], each = 5), y = rnorm(25)) aggregate(y ~ g, data = df, FUN = sum) g y 1 A -1.3165949 2 B 1.9850015 3 C -0.6460323 4 D -1.6459293 5 E 6.7001807 HTH, Dennis On Sun, Feb 13, 201

[R] summing values for specific variables

2011-02-13 Thread Jonathan Salerno
This is a seemingly simple problem, but I'm unable to make any progress. I have a large dataset, within it there is a column of location names, some of which repeat; the adjacent column lists values for each location name. I need to sum the values which correspond to the same location name, retur