Input Data Must Be Numeric????

So I am trying to use the Shannon index with delim.txt file but I keep getting the error message "input data must be numeric". What should I do?

data("Phylum")
diversity(Phylum, index = "Shannon")
Error in diversity(Phylum, index = "Shannon") :
input data must be numeric

What library are you using? Where is the ggplot (that you have tagged)? Can you provide something reproducible?

1 Like

First, Hi, please see the FAQ: What's a reproducible example (`reprex`) and how do I create one? Using a reprex, complete with representative data will attract quicker and more answers.

I'll have to guess that you are using diversity() from the vegan package . and that the source delim.txt file and Phylum are the same and contain either a lack of numeric variables or a mix of character and numeric variables.

The function signature requires its argument to be

Community data, a matrix-like object or a vector.

Matrices cannot mix classes--all numeric or all character.

This makes sense when you look at Shannon-Weaver

H = - \sum\limits_{i=1}^S p_i\space log\space p_i

gotta have numbers

2 Likes

I just figured that out but now it looks like the data looks incomplete (there is no full list of 52 variables), though it says it is there when I designated H. Does this look right or am I missing something? If it's correct, what should my next step be? Sorry I'm new at this

library(vegan)
data("Phylum")
diversity(Phylum, index = "shannon")
[1] 1.628674 1.532272 1.528529 1.564969 1.472072 1.496428 1.557890 1.641973
[9] 1.867042 1.859811 1.850034 1.827769
View(Phylum)
H <- diversity(Phylum, index = "shannon")

The next step is to give us a hint where to find the Phylum dataset

Would I need to use something like

data = read.delim(file.choose(), header =TRUE, sep = "\t")

If that works to bring it into your environment, great. To share use

dput(data)

and cut and paste the result enclosed by triple ticks or as a reprex.

If the data is way too long, just use

dput(head(data,100))
1 Like

Hello,
I would like to study specific diversity between several Islands. I have a problem with the constitution of my data. So, I can't use the "vegan" package.
I put Islands as individuals (the name of the cells) and Order, Family Gender and Species as variable. Can you explain to me how to put together the data table?
The idea is to study the diversity and the similarity among Islands and endemism.
thank you for helping me

Hi, and welcome!

Please see the FAQ: What's a reproducible example (`reprex`) and how do I do one? Using a reprex, complete with representative data will attract quicker and more answers.

I also suggest that you repost this as a new topic. A reprex isn't needed, because this isn't yet a coding question. It would help if you would confirm that

  1. All your variables are character
  2. They can be referred to as
  • islands
  • order
  • family
  • species
  • gender

and an idea of how many records you will be using and the form in which the data is now.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.