Re: [R] # values used in a function in tapply

2008-11-17 Thread Stephanie Shaw
Thank you, that took care of it! Stephanie On Mon, Nov 17, 2008 at 12:33 PM, Jorge Ivan Velez <[EMAIL PROTECTED] > wrote: > > Dear Sephanie, > Try the following: > > # Data set including some NA values > set.seed(123) > X=cbind(c(3, 2, 2, 1, 2, 5, 5, 4, 1, 1),matrix(rnorm(100),ncol=10)) > colname

Re: [R] # values used in a function in tapply

2008-11-17 Thread Jorge Ivan Velez
Dear Sephanie, Try the following: # Data set including some NA values set.seed(123) X=cbind(c(3, 2, 2, 1, 2, 5, 5, 4, 1, 1),matrix(rnorm(100),ncol=10)) colnames(X)=c('day',paste('X',1:10,sep="")) X[2,2]<-X[5,10]<-X[3,8]<-NA X # mean excluding NA values # in parenthesis are the number of observati

Re: [R] # values used in a function in tapply

2008-11-17 Thread Stephanie Shaw
Thank you very much for the suggestions, however I do not think they will help. Please let me know if I misunderstand. 1) Just using "colSums" without the "(!is.na)" portion provides: Error in FUN(X[[1L]], ...) : 'x' must be an array of at least two dimensions 2) In that context, sum appears

Re: [R] # values used in a function in tapply

2008-11-14 Thread jim holtman
Try something like this: amn <- tapply(a[,i], a[, 1], colSums, na.rm=TRUE)) but since the result of the tapply is a vector, you can also use: amn <- tapply(a[,i], a[, 1],sum, na.rm=TRUE)) On Fri, Nov 14, 2008 at 6:47 PM, Stephanie Shaw <[EMAIL PROTECTED]> wrote: > Hello, > > I am using tapply t

[R] # values used in a function in tapply

2008-11-14 Thread Stephanie Shaw
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 a