Otu table, integers and numeric

Hi im very new to R so this might be a basic question but I’m trying to calculate species number and richness from an otu table. I have the code I need however when I do it the output I get is NA for all my values. I looked it up and apparently this is because my data isn’t numeric, when I check using str it says my rows are all integers. Can anyone tell me how I change into numberic from integers?

I’ve attached a picture of the output from my str function to show that they are int (all the others not in the photo all say int too)
I’ve tried to change the data into numeric using as.integer but I’m not 100% sure I’m using it right and when I do I get an error message saying it can not be coerced to type integer, I have also tried using as.characters and it says about typing double


To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

1 Like

Hi I’m sorry I couldn’t figure out how to do reprex but here’s a photo which might show what my issue is

Photos are not very useful (also not a good thing to do here). It seems you are trying to convert your entire dataframe to numeric, but the as.numeric() function doesn't work that way, it takes vectors as input not dataframes, also integers are already numerics so very likely your problem has to do with something else like missing values (NAs) in your data.

Please try to read the reprex guide a little more carefully and make a reprex so we can better help you.

To install a package, you need to put character. Try


as shown in the documentation

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