# How to write a functional anova for different datasets in R language?

I am trying to make a functional ANOVA in R language that applies to different datasets in different conditions, but I am not able to make the code functional and appropriate in these different situations. How can I make the variable handling flexible so that the operator can choose? Example:

``````input <- data.frame(
order = gl(2,50, label = c(paste('area', LETTERS[1:2]))),
f1 = gl(5,10, label = c(paste('conc', LETTERS[1:5]))),
f2 = gl(5,2, label = c(paste('plot', LETTERS[1:5]))),
f3 = factor(rep(paste("cond", 1:2, sep =""), 5)),
values = abs(rnorm(100))
)

model <- by(input,input\$order, function(x){
f1 = levels(factor(x\$f1))
f2 = levels(factor(x\$f2))
f3 = levels(factor(x\$f3))
order = levels(factor(x\$order))

for( i in (1: length(f1))){
for(j in (1: length(order))){

di <- x[x\$f1 == f1[i] & x\$order == order[j] ,]

write(paste('\nf1:', "f1", f1[i],order[j],'\n'), stderr())
anova.1 <- aov(values ~ f2 * f3, di)

print(summary(anova.1))
}
}
write("Analyse Finished! \n", stderr())
})
``````

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.