Closed AaronLaycock closed 4 months ago
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.
The problem is due to this line: https://github.com/CCS-Lab/hBayesDM/blob/534907d9cbe7101b3109feeec808cdbd380a93f2/R/R/hBayesDM_model.R#L144
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 NA
s at all in the data frame then
if (is.null(data) || any(is.na(data)) || identical(data, "")) {
Thanks @steffen-stell for your suggestion. We will double check and fix the line in the next version.
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
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.
Hi @ChristinaWUUK, could you check if this would work?
devtools::install_github("CCS-Lab/hBayesDM", ref="develop", subdir="R")
@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)'
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
@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")))
@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.
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?
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"
)
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).