Are you please able to assist in performing a Krustal Wallis test using a subset of my data? I would like to be able to test for differences in "N" between "Producers".
names(Isotope.Data)
[1] "Species" "Name" "Group" "Simple_Group" "Trophic_Group"
[6] "Sample" "N" "C"
In my csv.file I have a column "Trophic Group" which separates Consumers and Producers.
table(Isotope.Data$Trophic_Group)
Consumer Producers
61 18
Under the column heading Simple_Group, I have three Producers - Rhodophyta, Seagrass and Phaeophyceae
table(Isotope.Data$Simple_Group)
Abalone Loliginidae Octopus Phaeophyceae Rhodophyta Seagrass Teleost
24 2 12 6 9 3 20
Tunicate
3
I have tried numerous things, but I get various error messages. Would anyone be able to improve on the following code?
kruskal.test(C ~ Simple_Group, data = Isotope.Data, subset = Isotope.Data$Trophic_Group = "Producers")
P.S. I have created a separate CSV.file which only includes Primary Producers. However a subsequent Dunn-test of multiple comparisons, used to determine which levels differed from each other provides different significance levels to those which includes both Consumers and Producers.
Will maybe this answer be helpful? Based on @user295691 answer:
Kruskal-Wallis test: create lapply function to subset data.frame?
Here you identify individual groups what you want to test differences between, and use split, to correctly define subsetting of your data frame.
Dummy example:
And now apply the
kruskal.testto each group usingsplit:or create a function:
Both produces test results for each group:
Or just get the p-values (notice the addition of
$p.valueafter thekruskal.test):