cjcarlson / embarcadero

🌲🌉 Species distribution models with Bayesian additive regression trees
49 stars 11 forks source link

Error in varim.diag "can't find `dropnames`" #20

Closed VirginiaMorera closed 3 years ago

VirginiaMorera commented 4 years ago

Hi,

Just encountered an error when running the variam.diag function on my data, so I decided to test it with the vignette and was able to reproduce the error.

When you run the line

varimp.diag(occ.df[,xnames], occ.df[,'Observed'], iter=50, quiet=TRUE)

it throws up the error

Error in select(., -dropnames) : unused argument (-dropnames)

Trying to figure out what was going on, I ran lines 31-33 from the varim.diag code

quietly(model.0 <- bart.flex(x.data = x.data, y.data = y.data, 
                           ri.data = ri.data,
                           n.trees = 200))

It turns out that

dput(unlist(attr(model.0$fit$data@x,"drop")) )

throws

c(x1 = FALSE, x2 = FALSE, x3 = FALSE, x4 = FALSE, x5 = FALSE, x6 = FALSE, x7 = FALSE, x8 = FALSE)

which is why the next line (#35)

 dropnames <- colnames(x.data)[!(colnames(x.data) %in% names(which(unlist(attr(model.0$fit$data@x,"drop"))==FALSE)))]

doesn''t assign anything to dropnames and then the function can't find the object.

Can't figure out anything beyond that, but then I tried variable.step which uses similar code, and it works! I hope this is helpful to find the issue!

Session info:

- Session info ------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 4.0.2 (2020-06-22)
 os       Windows 10 x64              
 system   x86_64, mingw32             
 ui       RStudio                     
 language (EN)                        
 collate  Spanish_Spain.1252          
 ctype    Spanish_Spain.1252          
 tz       Europe/Paris                
 date     2020-08-21                  
cjcarlson commented 4 years ago

Hey Virginia! This is unfortunately a Known Thing, but I did think it was fixed. Have you been running the most current version of embarcadero? If not I might ask you to send me an R session I can play with to debug this, because this needs to get fixed haha

VirginiaMorera commented 4 years ago

Hey Colin,

I think I am, yeah, embarcadero_1.2.0.0002 freshly downloaded this morning. Happy to help test stuff if you need me to!