I'm looking for help on performing the Kruskal-Wallis test on my set of data for a large number of factors. I can perform the test for a single factor, like AD_1yr:
kruskal.test(Shannon ~ AD_1y, data=comm)
But I have over 50 factors I want to test, and was hoping there is a code I can enter that will perform the test for all the factors without having to manually perform the test 50 different times.
We can use
lapplyto loop over thefactorcolumns, create adata.framewith the 'shannon' column and do thekruskal.testIf we need to extract the 'p.value', 'df', etc.