I have a dataframe like below:
I want to use Kruskal-Wallis test to compare compound 1 in group A, B, C, D's concentration. For example, compound 1, group A with group B, compare their concentration. The comparison should be made between different group within same compound. Group comparison should be as below.
I tried the code like below
# Performing Kruskal-Wallis test
kruskal.test(Group~Concentration, data = df) )
But it use all Group A data (include compound1, compound2, ...). I want to compare within one compound, how to change the code?