A subset of my raw data looks like this: -------------- "Grip" "Technique" "Baseline.integrated" "Task" "Stroke..direction." "Engag" "Disen" "PenDG" "PenUG" "PenDS" "PenUS" "Duration" ------------- "Tripod","Barrel","Integrated",7,"S70",230,510,270,510,781,1011,1011 "Tripod","Barrel","Integrated",7,"S71","na","na","na","na","na","na","na" "Round","NonPrefHand","Baseline",0,"S00","na","na",110,250,380,520,520 "Round","NonPrefHand","Baseline",0,"S01","na","na",220,360,460,620,620 --------------
I computed some values (times) from the raw data --------------- t_p1=PenDG t_c1=PenUG-PenDG t_p2=PenDS-PenUG t_c2=PenUS-PenDS --------------- And I put those times in a data frame called "times". For each of these times, I want to subtract the average for "Baseline" trials from the average for "Integrated" trials within the "Grip" and "Technique" factors. Call these differences the true cost of mode selection. > truecost <- function(time){as.numeric(tapply(time,Baseline.integrated,mean,na.rm=T)[2]-tapply(time,Baseline.integrated,mean,na.rm=T)[1])} To help explain what the truecost function does: > tapply(t_p1,Baseline.integrated,mean,na.rm=T) Baseline Integrated 212.8000 252.8402 > truecost(t_p1) [1] 40.04021 Then I try to create a table of average truecost as a function of levels of a factor. I think this is the same error with tapply and by. > tapply(t_p1,list(Grip,Technique),truecost,na.rm=T) Error in FUN(X[[1L]], ...) : unused argument(s) (na.rm = TRUE) > by(times,list(Grip,Technique),truecost,na.rm=T) Error in FUN(data[x, , drop = FALSE], ...) : unused argument(s) (na.rm = TRUE) Any ideas? Thomas Levine! [[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.