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

hBayesDM package error in R 4.2.2 #153

Closed
AaronLaycock opened this issue Feb 7, 2023 · 12 comments
Closed

hBayesDM package error in R 4.2.2 #153

AaronLaycock opened this issue Feb 7, 2023 · 12 comments
Assignees

Comments

@AaronLaycock
Copy link

Hi all,

FYI

After experiencing difficulties (PSA) running an ORL model using the hBayesDM package in R version 4.2.2 (with the appropriate version of Rtools), the issue was rectified when I regressed to R version 4.1.3 (and associated Rtools package).

error

@plonskipe
Copy link

having trouble with dd_hyperbolic too. I think it's related to https://stackoverflow.com/questions/72848442/r-warning-lengthx-2-1-in-coercion-to-logical1
"example" data runs fine but input data frames result in the error:
Error in is.null(data) || is.na(data) :
'length = 8568' in coercion to 'logical(1)'
where the length is the number of cells in the data frame. Clash with a single logical on the other side.

@steffen-stell
Copy link
Contributor

The problem is due to this line:

if (is.null(data) || is.na(data) || data == "") {

This test makes no sense. Both is.na(data) and data == "" produce matrices of element-wise checks for a data frame input. In older versions of R these were coerced to scalar by just taking the first element of the matrix. In newer versions it just results in an error, because if(), || and && take only scalars. If you want to check for scalar NA, this should be something like

    if (is.null(data) || identical(data, NA) || identical(data, "")) {

or if there must be no NAs at all in the data frame then

    if (is.null(data) || any(is.na(data)) || identical(data, "")) {

@youngahn
Copy link
Member

youngahn commented Jul 3, 2023

Thanks @steffen-stell for your suggestion. We will double check and fix the line in the next version.

@ChristinaWUUK
Copy link

Hi everyone, I encounter the same issue. is there a version that is now working or do you know how to fix this? many thanks

@AaronLaycock
Copy link
Author

Hey ChristinaWUUK, I am not aware of when to expect any updates to the package. That said, I did have to re-run some analysis recently and the package worked fine once I reverted back to the appropriate archived versions of R and Rtools.

@youngahn
Copy link
Member

Hi @ChristinaWUUK, could you check if this would work?

devtools::install_github("CCS-Lab/hBayesDM", ref="develop", subdir="R")

@lukasgunschera
Copy link

@youngahn I am experiencing the same issue - for me, using the above installation does not resolve the

Error in is.null(data) || is.na(data) : 'length = 16000' in coercion to 'logical(1)'

@ChristinaWUUK
Copy link

Thank you @youngahn, really appreciate your promt response to help! I tried installing from github, however, I later on got stuck with the running bandit2arm_delta (Error in stanc(file = file, model_code = model_code, model_name = model_name, :
Empty or invalid filename!). I ended up installing a previous version of R (4.1.3) and this worked @lukasgunschera

@ChristinaWUUK
Copy link

@AaronLaycock thanks! which version of R and R tools did you use? It worked fine with R 4.1.3 and Rtools 4.0 but i did have to install install.packages("StanHeaders", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))

@AaronLaycock
Copy link
Author

@ChristinaWUUK, no worries. Great news, it's working. I used R version 4.1.3 with Rtools 4.0 also, it ran with no problems from the initial download.

@lukasgunschera
Copy link

Thank you @ChristinaWUUK @AaronLaycock - it works fine after reverting to R 4.1.3.
Has anyone attempted to implement @steffen-stell's solution in 4.3.3?

@steffen-stell
Copy link
Contributor

Since people keep asking and this is a fairly simple issue to fix, I have made PR #161. You can install it like this:

devtools::install_github(
  repo = "CCS-Lab/hBayesDM",
  ref = "627c1ea35121b85760fdddec68583e82431c06e6", 
  subdir = "R"
  )

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

8 participants