Error in diversity(x, index = "shannon") : input data must be numeric #481
Replies: 1 comment
-
I think the error message is clear: You can remove columns using negative indexing (and you do not need to use H <- diversity(nativeAB[, -(1:4)]) # removes cols 1 to 4, but check the actual indexing in your data As a non-vegan issue: The last rows of your example are a mystery to me, as I have no idea what is function |
Beta Was this translation helpful? Give feedback.
-
Hello everyone,
I have tried running the analysis which aims to plot Shannon diversity index across land-use types.
However, upon running the H line I got the error message:
H <- apply(nativeAB, MARGIN = 1,FUN = diversity, index="shannon")
Error in FUN(newX[, i], ...) : input data must be numeric
Below are my script and data attached.
nativeAB = read.csv('all_transposedDR.csv')#Read data
head(nativeAB)#look at first 6 rows
str(nativeAB)
A plot of Shannon-Wiener H' across the three land-use types
library(vegan)
H <- apply(nativeAB, MARGIN = 1,FUN = diversity, index="shannon")
H
CI<- apply(nativeAB, MARGIN = 1, FUN = H_CI)
CI
diversitybarplot <- barplot(shannon, ylim = c(0, max(H+CI)), cex.names = 0.8)
arrows(diversitybarplot, H+CI, diversitybarplot, H-CI, length = 0.1, angle = 90, code = 3)
title(xlab = "land use types", ylab = "Shannon-Wiener H' index")
Copy of all_transposedDR.xlsx
Beta Was this translation helpful? Give feedback.
All reactions