Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XData cannot be a tibble #37

Open
FabianRoger opened this issue Dec 16, 2019 · 1 comment
Open

XData cannot be a tibble #37

FabianRoger opened this issue Dec 16, 2019 · 1 comment

Comments

@FabianRoger
Copy link

FabianRoger commented Dec 16, 2019

If XDatais a tibble instead of a data.frame the function fails with

Error in switch(class(XData), list = { : EXPR must be a length 1 vector

the error message comes from the call to switch in switch(class(XData), ... as class(XData) gives [1] "tbl_df" "tbl" "data.frame" and thus a vector of length 3, if XData is a tibble.

repex:

Y = matrix(rpois(100, 2), nrow = 5)

XData = tibble(A = rnorm(20, 2,1),
               B = rnorm(20, 5, 2))

Hmsc(Y = Y, XData = XData, XFormula = ~A+B)

Just wanted to let you know as many people might use tibbles these days and the error message is pretty cryptic.

@jarioksa
Copy link
Collaborator

New version of Hmsc was released today on CRAN, and it fixes this error message. However, it may still fail as we are only prepared to handle data.frame or a list of data frames, and tibble seems to be neither. You may check with the latest version (3.0-4).

The fix looks obvious, though, and tibbles could be treated similarly as data frames as they inherit from data.frame.

jarioksa added a commit to jarioksa/HMSC that referenced this issue Apr 9, 2020
jarioksa added a commit that referenced this issue Apr 23, 2020
- species data Y can be a data frame or in univariate models a vector
- dist(ibution) names can be abbreviated, and more informative error message
- XData can be a tibble (wish of issue #37)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants