I am looking to find the sum of certain columns in my dataset. currently it looks something like this.
I want to find the column sum of everyone in X, Y and Z for each possible grid and month combination. Currently I have
xx<-data[data$Month=="November"&data$grid=="A3",]
fun<-by(xx[, 1:3],xx$grid, colSums,na.rm=T)
fun<-as.character(fun)
as.data.frame(fun,
stringsAsFactors = default.stringsAsFactors())
But this requires me to change the grid ref and month ref each time, is there a simpler way to do it without manually specifying which grids and months I want.