Re: [R] summing NAs in aggregate

2012-01-11 Thread R. Michael Weylandt
Perhaps this would work: spitzSum <- function(x) if(all(is.na(x))) NA else sum(x, na.rm = TRUE) Michael On Wed, Jan 11, 2012 at 11:18 PM, Spitzer, Matthew wrote: > Hello, > I would like to please ask for assistance with aggregate sum.  I have a data > set with consisting of two grouping variab

[R] summing NAs in aggregate

2012-01-11 Thread Spitzer, Matthew
Hello, I would like to please ask for assistance with aggregate sum. I have a data set with consisting of two grouping variables (id, visit) and several other variables. I would like to sum the variables for each id and visit, but am having problems with na.rm. na.rm=TRUE seems to replace all