Please permit that I first reproduce some data in the same format as yours:

fungi_vector <- data.frame(
  tmp_vector = c(rnorm(10, 0.7, 0.1), rnorm(10, 0.2, 0.1)),
  labels = c(rep('Ascomycota', 10), rep('Basidiomycota', 10)))
fungi_vector$tmp_vector <- as.character(fungi_vector$tmp_vector)
'data.frame':   20 obs. of  2 variables:
 $ tmp_vector: chr  "0.651365595291301" "0.661684503596836" "0.755288193037626" "0.666716503201382" ...
 $ labels    : chr  "Ascomycota" "Ascomycota" "Ascomycota" "Ascomycota" ...

Então / So, the first issue is that your column of numbers is encoded as characters; so, we first need to convert that to numerical values:

fungi_vector$tmp_vector <- as.numeric(fungi_vector$tmp_vector)

To be proper, we should also convert the second column to categorical values:

fungi_vector$labels <- factor(fungi_vector$labels,
  levels = c('Ascomycota','Basidiomycota'))

Then, a Kruskal Wallis test can be done like this:

kruskal.test(tmp_vector ~ labels, fungi_vector)

    Kruskal-Wallis rank sum test

data:  tmp_vector by labels
Kruskal-Wallis chi-squared = 14.286, df = 1, p-value = 0.0001571

For my 'manufactured' data, I already knew that the p-value would be statistically significant due to the fact that I had pre-selected different means via rnorm() (see above).

We can also plot this:

boxplot(tmp_vector ~ labels, fungi_vector)


I will leave the remainder to you.

Kind regards,


Source link