r - Using a 'complex' function within the apply family -
i attempting use aov() function within tapply() line, , not sure if not possible, or if i'm coding incorrectly. factors<-c("factor 1", "factor 2") years<-c("year 1", "year 2", "year 3","year 4", "year 5") width<-rnorm(100) height<-rnorm(100) mydata<-data.frame(years,factors,width,height) i see if there difference between factor levels each year. note real data has several factor levels, why i'm using anova , not t-test. i can tapply() 'simple' functions, sum : with(mydata,tapply(width,factors,fun="sum")) from simple examples, think way tapply() works subsets data 2nd entry, factors , takes first entry, width , , put's whatever function declared. reasoning, tried: with(mydata,tapply(width~factors,years,fun="aov")) this returns error arguments must have same length . if possible use tapply function requires complex input, how go doing this...