adeverse / ade4

Analysis of Ecological Data : Exploratory and Euclidean Methods in Environmental Sciences
http://adeverse.github.io/ade4/
39 stars 10 forks source link

Imrpove the managing of calls to eval in randtest.rlq #21

Open sdray opened 4 years ago

sdray commented 4 years ago

The issue appears when a table is named T (e.g., for traits). In this case, the randtest.rlq methods (but it should be the same for other methods that use 'eval' to retrieve objects) wrongly evaluates the object (as TRUE instead of the data.frame) but the code runs wrongly without returning any error.

E <- data.frame(matrix(rnorm(30), nrow = 15))
T <- data.frame(matrix(rnorm(30), nrow = 10))
L <- data.frame(matrix(rpois(lambda = 15, 150), nrow = 15))
coa <- dudi.coa(L, scannf = FALSE)
pcaT <- dudi.pca(T, row.w = coa$cw, scannf = FALSE)
pcaE <- dudi.pca(E, row.w = coa$lw, scannf = FALSE)
rlq1 <- rlq(pcaE, coa, pcaT, scannf = FALSE)
sum(rlq1$eig)
randtest(rlq1)

Solution would be to correctly manage the original object T or at least returns an error.