Hello, I am using tapply to pull out data by the day of week and then perform functions (e.g. mean). I would like to have the number of values used for the calcuation for the functions, sorted by each day of week. A number of entries in any given column are NAs.
I have tried the following code and simple variants with no luck. for (i in 1:length(a[1,])){ x<-tapply(a[,i],a[,1],mean, na.rm=TRUE) amn<-tapply(a[,i],a[,1],colSums(!is.na),na.rm=T)} Adding an explicit argument to colSums(!is.na) {e.g. colSums(!is.na(a[,i]))} produced an error that said colSums was not a function. Trying an imbedded tapply instead of the colSums didn't work either. Using the sum function added the values, not the count of the values. Thank you for any suggestions, Stephanie [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.