Dear all, I want to calculate mean values for multiple rows:
structure(list(Name = structure(c(1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L), .Label = c("AKT", "CKT"), class = "factor"), val1 = c(2, 3, 2, 2, 2, 5, 3, 8, 2), val2. = c(4, 5, 4, 8, 4, 8, 4, 7, 4), val3 = c(5, 6, 5, 9, 5, 9, 5, 9, 5)), .Names = c("Name", "val1", "val2.", "val3"), class = "data.frame", row.names = c(NA, 9L)) For example: as an output I must get Name val1 val2 val3 AKT CKT I wrote this : #as.matrix(tapply(dat[,2:4], dat[,1], FUN = mean)) Error in as.matrix(tapply(met[, 2:4], met[, 1], FUN = mean)) : error in evaluating the argument 'x' in selecting a method for function 'as.matrix': Error in tapply(met[, 2:4], met[, 1], FUN = mean) : arguments must have same length Thanks for you kind advise Nico [[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.