I keep getting this error:Error in rowSums(veg) :
'x' must be numeric
I subsetted from a large dataset a small portion and when I run the DCA ordination I keep getting the above mentioned error message. I checked, but I have no character data in de rows present.
install.packages("vegan")
library(vegan)
Dataveg2018A <- subset(DatasetMerg, Year == "2018" & Block == "A",
select = 4:7)
ord1<-decorana(Dataveg2018A)
can someone please tell me what I am doing wrong?
example data of subset (DatasetMerg)
structure(list(Year = structure(c(3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Names = c("18A01",
"18A02", "18A03", "18A04", "18A05", "18A06", "18A07", "18A08",
"18A09", "18A10", "18A11", "18A12", "18A13", "18A14", "18A15",
"18A16", "18A17", "18A18", "18A19", "18A20"), .Label = c("2001",
"2008", "2018"), class = "factor"), Block = structure(c(1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L), .Names = c("18A01", "18A02", "18A03", "18A04", "18A05",
"18A06", "18A07", "18A08", "18A09", "18A10", "18A11", "18A12",
"18A13", "18A14", "18A15", "18A16", "18A17", "18A18", "18A19",
"18A20"), .Label = c("A", "B", "C", "D", "E", "F", "G", "H",
"I", "J", "X"), class = "factor"), Plot = structure(1:20, .Names = c("18A01",
"18A02", "18A03", "18A04", "18A05", "18A06", "18A07", "18A08",
"18A09", "18A10", "18A11", "18A12", "18A13", "18A14", "18A15",
"18A16", "18A17", "18A18", "18A19", "18A20"), .Label = c(" 1",
" 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10", "11", "12",
"13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23",
"24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34",
"35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45",
"46"), class = "factor"), Agrimonia.eupatoria = structure(c(3L,
2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L), .Names = c("18A01", "18A02", "18A03", "18A04", "18A05",
"18A06", "18A07", "18A08", "18A09", "18A10", "18A11", "18A12",
"18A13", "18A14", "18A15", "18A16", "18A17", "18A18", "18A19",
"18A20"), .Label = c("0", "1", "2", "6"), class = "factor"),
Agrostis.capillaris = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Names = c("18A01",
"18A02", "18A03", "18A04", "18A05", "18A06", "18A07", "18A08",
"18A09", "18A10", "18A11", "18A12", "18A13", "18A14", "18A15",
"18A16", "18A17", "18A18", "18A19", "18A20"), .Label = c("0",
"2", "3", "4", "6"), class = "factor"), Agrostis.gigantea = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 3L, 2L, 1L, 3L, 3L,
4L, 3L, 1L, 1L), .Names = c("18A01", "18A02", "18A03", "18A04",
"18A05", "18A06", "18A07", "18A08", "18A09", "18A10", "18A11",
"18A12", "18A13", "18A14", "18A15", "18A16", "18A17", "18A18",
"18A19", "18A20"), .Label = c("0", "2", "3", "4", "6"), class = "factor"),
Agrostis.stolonifera = structure(c(5L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Names = c("18A01",
"18A02", "18A03", "18A04", "18A05", "18A06", "18A07", "18A08",
"18A09", "18A10", "18A11", "18A12", "18A13", "18A14", "18A15",
"18A16", "18A17", "18A18", "18A19", "18A20"), .Label = c("0",
"1", "18", "2", "3", "38", "4", "6", "68", "8"), class = "factor")),
.Names = c("Year",
"Block", "Plot", "Agrimonia.eupatoria", "Agrostis.capillaris",
"Agrostis.gigantea", "Agrostis.stolonifera"), row.names = c("18A01",
"18A02", "18A03", "18A04", "18A05", "18A06", "18A07", "18A08",
"18A09", "18A10", "18A11", "18A12", "18A13", "18A14", "18A15",
"18A16", "18A17", "18A18", "18A19", "18A20"), class = "data.frame")
All your variables are non-numeric (factors), both in the original DatasetMerg
and its subset (Dataveg2018A
). You can see this issuing command str(DatasetMerg)
which gives all variables as factors (and same for its subset). You can also see this in your own display of the full DatasetMerg
, where all species data are given as factors. Here is just the first of your species, for which you give the data as:
Agrostis.capillaris = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Names = c("18A01",
"18A02", "18A03", "18A04", "18A05", "18A06", "18A07", "18A08",
"18A09", "18A10", "18A11", "18A12", "18A13", "18A14", "18A15",
"18A16", "18A17", "18A18", "18A19", "18A20"), .Label = c("0",
"2", "3", "4", "6"), class = "factor")
Please note the last definition class = "factor"
. The values (all 1L
) give the index of your factor level, and these levels are given in .Label
. So all your data are ones (1L
) and these are displayed as .Labels[1L] == c("0", "2", "3", "4", "6")[1L] == "0"
which is non-numeric (a character).