I am trying to generate statistics test result from ANOVA and TukeyHSD tests. There were several repetitions to be done from markerlist
and crosslist
.
markerlist
contains a list of markers: (eg)
M011
M023
M820...
crosslist
contains another list: (eg)
DMD7
DMD34
DMD50
DMD51...
The data types:
> class(crosslist)
[1] "character"
> class(markerlist)
[1] "list"
I wanted to get the result for both ANOVA and TukeyHSD test at once, for each marker at each cross list. I have reached the following script:
for (i in markerlist){
for (j in crosslist){
Fmarker <- as.formula(paste("z3 ~", i))
cross <- get(j)
anova_out <- summary(aov(Fmarker, data=cross))
aov_fstat <- anova_out[[1]]$F[1]
tukey <- TukeyHSD(aov(Fmarker, data=cross))
output_data <- data.frame(
variable = i,
anova_F = anova_out,
PostHoc_TukeyHSD = tukey
)
print(output_data)
output_file <- paste("aov_", i, "_", j, ".csv", sep="")
write.csv(output_data, file=output_file, row.names=FALSE)
}
}
But something is wrong with the script.
Error in get(j) : object 'DMD7' not found
What is wrong here? Any help would be greatly appreciated!