adeverse / ade4

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

niche.param(x) requires `x$call[[2]]` to still be in the environment #14

Open wlandau opened 5 years ago

wlandau commented 5 years ago

From @Rekyt via https://github.com/ropensci/drake/issues/590:

library(ade4)
data(doubs)
dudi1 <- dudi.pca(doubs$env, scale = TRUE, scan = FALSE, nf = 3)
nic1 <- niche(dudi1, doubs$fish, scann = FALSE)
omi <- niche.param(nic1)
rm(dudi1)
omi <- niche.param(nic1)
#> Error in eval(expr, p): object 'dudi1' not found

If nic1 really needs dudi1 in order to use niche.param(), is there some way to make sure the value of dudi1 gets passed along with nic1? Maybe in a new list element of nic1 or another argument to niche.param()?

sdray commented 5 years ago

In ade4, many methods use this way to deal with previous analyses without storing objects. I know this is probably not the best way but it would require too much work to modify in all functions.