Hi all,
I wonder if you could help me with (what is surely) a simple R question?
I've written a simple R script (attached) to perform multiple ANOVAs
on the columns in a table loaded in from a a file (also attached). I
loop through the list of columns for which I want to perform the
ANOVAs, storing the column name in a variable. When I try to perform
the ANOVA using the variable name as a reference to the column name R
complains as follows:
Error in the model.frame(formula, rownames, variables, varnames,
extras, extranames, :
invalid variable type
The line causing the problem is the first line inside the for loop.
The question is what have I done wrong? Is there a better way of doing
the ANOVAs?
Thanks in advance,
Bye,
Colm.
-------------- next part --------------
roi.errs=read.table("../Group.results/allGroupsROI.errs", header=T,
sep="\t");
roi.stops=read.table("../Group.results/allGroupsROI.stops", header=T,
sep="\t");
# extract the names of the columns containing the means
roi.names=names(roi.errs);
meanColumns=roi.names[4:length(roi.names)];
## open the output file, split=T also spits it to the screen
sink("../Group.results/ROI.errs.txt",split=T)
cat("********************************************************************************\n");
cat("*** Summary for ROI.errs\n");
for (meanCol in meanColumns) {
roi.err.aov<-aov(meanCol ~ Group, data=roi.errs);
cat("********************************************************************************\n");
cat("*** Summary of AOV for ", meanCol, "\n");
summary(roi.err.aov);
}
## close the output file
sink();
## open the output file, split=T also spits it to the screen
sink("../Group.results/ROI.stops.txt",split=T)
cat("********************************************************************************\n");
cat("*** Summary for ROI.stops\n");
for (meanCol in meanColumns) {
roi.stops.aov<-aov(meanCol ~ Group, data=roi.stops);
cat("********************************************************************************\n");
cat("*** Summary of AOV for ", meanCol, "\n");
summary(roi.stops.aov);
}
## close the output file
sink();