I get the following error:
ex3 <- dbFD(mg2, AbundanciaxSp2, message = FALSE, w.abun = TRUE)
Error in dbFD(mg2, AbundanciaxSp2, message = FALSE, w.abun = TRUE) :
Different number of species in 'x' and 'a'.
I have already tested by checking: Extra blanks, invisible special characters, check number of species in mg2 and AbundancexSp2 . Here is an example of my data from both matrices and the scrip to see if I have any steps wrong.
AbundanciaxSp2_data <- data.frame(
Species = c("Prionospio", "Magelona", "M.schu", "N.isab", "Cirratulidae", "O.tegu"),
CNA1 = c(0, 20, 0, 680, 0, 80),
CNA2 = c(0, 40, 0, 340, 0, 20),
CNA3 = c(0, 0, 0, 360, 0, 0),
CNA4 = c(0, 20, 0, 160, 0, 140),
CNA5 = c(0, 0, 220, 0, 60, 0),
CNA6 = c(0, 0, 40, 40, 0, 0),
CNA7 = c(0, 0, 0, 20, 40, 0),
CNA8 = c(0, 0, 0, 0, 0, 0),
CSA1 = c(0, 0, 0, 140, 0, 100),
CSA2 = c(0, 0, 0, 80, 0, 180),
CSA3 = c(0, 0, 0, 60, 0, 40),
CSA4 = c(0, 260, 0, 420, 0, 80),
CSA5 = c(0, 0, 0, 140, 0, 100),
CSA6 = c(0, 0, 0, 80, 0, 180),
CSA7 = c(0, 0, 0, 60, 0, 40),
ONA1 = c(0, 0, 0, 140, 0, 100),
ONA2 = c(0, 0, 0, 80, 0, 180),
ONA3 = c(0, 0, 0, 60, 0, 40),
ONA4 = c(0, 0, 0, 420, 0, 80),
ONA5 = c(0, 0, 0, 140, 0, 100),
ONA6 = c(0, 0, 0, 80, 0, 180),
ONA7 = c(0, 0, 0, 60, 0, 40),
ONA8 = c(0, 0, 0, 420, 0, 80)
)
Spxtraits2_data <- data.frame(
Species = c("Prionospio", "Magelona", "M.schu", "N.isab", "Cirratulidae", "O.tegu"),
small = c(3, 0, 0, 1, 3, 0),
medio = c(0, 0, 0, 0, 0, 3),
large = c(0, 0, 0, 0, 0, 0),
deposit = c(1.5, 1, 0, 0, 2.5, 1.5),
filter = c(1.5, 2, 2, 0, 0.5, 1.5),
predator = c(0, 0, 0, 3, 0, 0),
low = c(3, 0, 1.5, 3, 3, 0),
medioo = c(0, 3, 0, 0, 0, 0),
high = c(0, 0, 0, 0, 0, 0),
indirect = c(3, 3, 3, 3, 3, 0),
direct = c(3, 3, 3, 3, 3, 0)
)
library(FD)
library(gawdis)
Bodysize.fuzzy <- cbind(Spxtraits2$small, Spxtraits2$medio, Spxtraits2$large)
Feeding.fuzzy <- cbind(Spxtraits2$deposit, Spxtraits2$filter, Spxtraits2$predator)
Mobility.fuzzy <- cbind(Spxtraits2$low, Spxtraits2$medioo, Spxtraits2$high)
Development.fuzzy <- cbind(Spxtraits2$indirect, Spxtraits2$direct)
rownames(Bodysize.fuzzy)<-paste(Spxtraits2$Species, 2:11)
rownames(Feeding.fuzzy)<-paste(Spxtraits2$Species, 2:11)
rownames(Mobility.fuzzy)<-paste(Spxtraits2$Species, 2:11)
rownames(Development.fuzzy)<-paste(Spxtraits2$Species, 2:11)
tabla <- as.data.frame(cbind(Bodysize.fuzzy, Feeding.fuzzy, Mobility.fuzzy, Development.fuzzy))
tabla
mg2 <- as.matrix(gawdis(tabla, w.type = "equal", groups = c(1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4), fuzzy = TRUE))
mg2
ex3 <- dbFD(mg2, AbundanciaxSp2, message = FALSE)