You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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
- 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)
If
XData
is a tibble instead of a data.frame the function fails withError in switch(class(XData), list = { : EXPR must be a length 1 vector
the error message comes from the call to
switch
inswitch(class(XData), ...
asclass(XData)
gives[1] "tbl_df" "tbl" "data.frame"
and thus a vector of length 3, ifXData
is a tibble.repex:
Just wanted to let you know as many people might use tibbles these days and the error message is pretty cryptic.
The text was updated successfully, but these errors were encountered: