geomorphR/geomorph

procD.lm can't be included in a function

Closed this issue · 1 comments

This makes it really hard to program against geomorph.

This example works as expected:

library("geomorph")
data(plethodon)
gpa <- gpagen(plethodon$land, ShowPlot = FALSE)
procD.lm(gpa$coords ~ plethodon$species, iter = 9)

This example doesn't work, but should:

f1 <- function(coords, x) {
    procD.lm(coords ~ x, iter=9)
}
f1(gpa$coords, plethodon$species)
Error in eval(expr, envir, enclos) : object 'x' not found 
6 eval(expr, envir, enclos) 
5 eval(predvars, data, env) 
4 model.frame.default(Terms) 
3 model.frame(Terms) 
2 procD.lm(coords ~ x, iter = 9) 
1 f1(gpa$coords, plethodon$species) 

I haven't tested the other functions (like advanced.procD.lm) but I suspect similar issues exist.

Jonathon,

We had the same error although for some reason your code started to work for me without any adjustment. I do not understand this; it just started working after several failed attempts, without any apparent manipulation. However, we found more universally that there seems to be a problem with the $ operator and the model.frame base function within our functions. Changing variables seems to alleviate this. For example, before running your function, this augmentation worked for us
Y <- gpa$coords
X <- plethodon$species

Then run the f1 function with Y and X.

I'm not sure if this helps your needs. We ran into several issues recently when CRAN updated the model.frame family of functions that apparently we still need to address in some respects.

Thanks for the alert. This will help us as we update our package.

Mike

Sent from my iPhone

On May 30, 2015, at 4:26 PM, Jonathan Chang notifications@github.com wrote:

This makes it really hard to program against geomorph.

This example works as expected:

library("geomorph")
data(plethodon)
gpa <- gpagen(plethodon$land, ShowPlot = FALSE)
procD.lm(gpa$coords ~ plethodon$species, iter = 9)
This example doesn't work, but should:

f1 <- function(coords, x) {
procD.lm(coords ~ x, iter=9)
}
f1(gpa$coords, plethodon$species)
Error in eval(expr, envir, enclos) : object 'x' not found
6 eval(expr, envir, enclos)
5 eval(predvars, data, env)
4 model.frame.default(Terms)
3 model.frame(Terms)
2 procD.lm(coords ~ x, iter = 9)
1 f1(gpa$coords, plethodon$species)
I haven't tested the other functions (like advanced.procD.lm) but I suspect similar issues exist.


Reply to this email directly or view it on GitHub.