Hello everyone,
I've come to you with a question, please bear with me as I am pretty new to R in general.
Here is the problem:
I need to make a diversity index from a data table in R, and for this I found I could use the package "vegan".
Here is what I did:
simpson_diversity <- diversity(comT, index = "simpson")
where comT is the data frame with the data
console answers:
Error in diversity(comT, index = "simpson") : input data must be numeric
Indeed, the data I am using contains observations of species written in the format "character"."character"
example: u.u j.k l.m
Is there a way I can use an other function to directly interpret the characters?
Otherwise, how can I encode the characters as numbers?
I have tried filtering the data frame by unique values with:
unique_values<-unique(comT)
which gave /
[[1]]
[1] "f.i"
[[2]]
[1] "w.l"
[[3]]
[1] "t.w"
[[4]]
[1] "q.x"
[[5]]
[1] "e.n"
yet I am not sure how to make these match to the original data frame.
Thank you for your help,