-1

I believe I'm struggling with a data frame issue. In my data set, my first column is site names, call them Tech 1 through Tech 8. The rest of my columns are each assigned to one species, with binary 0s or 1s beneath to signify their presence in each site. Every time I use the specaccum function, it spits back "Error in colSums(x): 'x' must be numeric". Removing the first column results in only 1 site and errors, but including the column only results in more errors. How can I manipulate my data frame such that the first column becomes the site names? Thanks in advance

1 Answers1

1

Here is a simple solution

library(vegan)

#I suppose your data is something like this
df<-data.frame(Sites = paste("Tech",1:20),
           Sp1 = rep(c(1,0),each=10),
           Sp2 = rep(c(1,0,0,1),each=5),
           Sp3 = rep(c(0,1,0,1),each=5))

#Change df from data.frame to numeric matrix, excluding the first column
mat<-data.matrix(df[,-1])
#Add first column as row names
row.names(mat)<-df[,1]
#Apply specaccum function
specaccum(mat)