Reputation: 11
When I do:
kruskal.test(sapply(list$`sublist`, "[", 14))
I am able to run the test on the 14th column of each data frame within the sublist.
However, I need to run this on over 1000 sublists, so individually writing it out isn't an option. Any suggestions how to access the 14th column of each of the data frames within each individual sublist to run a Kruskal Wallis test on the data from that sublist only?
Basically, I just need a way to loop through the sublists, but I am not sure how to do that.
Thanks for your help!
Upvotes: 1
Views: 57
Reputation: 79338
Just add another *apply function before it:
lapply(list function(i) kruskal.test(sapply(i, "[", 14)))
Upvotes: 1