One-way ANOVA for loop: how do I initiate through multiple colums of a dataframe

It's very much my first time on here, so please go easy.
I want to run more than 1000 different one way ANOVA's (if you are allowed to do that with the given data)
I would like to see if the number of reads from a single miroRNA changes between four different groups.
And I would like that from each of the more than 1000 miRNAs.
my tibble dataframe looks like this (small excerpt from the entire table):
I have my 4 groups (YC, OC, YH, OH) and a different miRNA in each column.


If I were to do it by hand, I would run a one-way ANOVA for each individual micoRNA to determine whether the expression of the respective microRNA differs between the groups. Now it would of course be great if R would do these individual comparisons for me and just spit out a table which miRNAs are even interesting because there are differences between the groups.


  • stringsAsFactors = FALSE,
  •      row.names = c("1", "2", "3", "4", "5", "6", "10", "11", "12"),
  •          Group = c("YC", "YC", "YC", "OC", "OC", "OC", "OH", "OH", "OH"),
  •           miR1 = c(0, 4.92, 0, 0, 0, 6.9, 130.71, 185.86, 538.57),
  •           miR2 = c(0, 4.92, 0, 0, 0, 6.9, 130.71, 185.86, 538.57),
  •           miR3 = c(1709.72,1807.43,1288.85,
  •                    1077.87,1520.88,837.3,2105.27,1205.27,2888.99),
  •           miR4 = c(26848.3,41985.08,16395.77,
  •                    38553.33,34635.5,20872.5,26025.05,37425.35,29067.08),
  •           miR5 = c(34.45,14.31,53.65,40.67,
  •                    77.93,43.78,52.91,0,26.77),
  •           miR6 = c(57183.95,84658.81,32683.29,
  •                    79686.11,61316.75,38260.51,40056.43,66675.7,57326.29)
  • )

I tried a for-loop through which I expect R to iterate through the name of the miRNAs and then summaries an ANOVA table and TukeyHSD test:

for(i in 2:ncol(test)){column<-names(test[i])AVz<-summary(aov(test[,i]~Group,data = test))tk<-TukeyHSD((aov(test[,i]~Group,data = test)))print(column)print(AVz)print(tk)}

unfortunately that didn't work at all.
Error: unexpected symbol in "for(i in 2:ncol(test)){column<-names(test[i])AVz"
I would be really grateful for help !!

See the FAQ: How to do a minimal reproducible example reprex for beginners. Representative data relieves the need to reverse engineer the problem, which will give a better chance of a helpful answer.

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.