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

Error when passing tibble #12

Open
johnsonra opened this issue Apr 27, 2023 · 2 comments
Open

Error when passing tibble #12

johnsonra opened this issue Apr 27, 2023 · 2 comments

Comments

@johnsonra
Copy link

I'm getting the following error when passing a tibble. I'm guessing this is the same problem that was reported in Issue #8.

Example

library(dplyr)
library(JointAI)

set.seed(284397)
lm_imp(y ~ x,
       data = tibble(y = rnorm(100),
                     x = c(rnorm(99), NA)))

## Error in is.nan(data[, k]) : 
##  default method not implemented for type 'list'

Work around

Convert tibbles to data.frames:

lm_imp(y ~ x,
       data = tibble(y = rnorm(100),
                     x = c(rnorm(99), NA)) %>%
         as.data.frame())

## Note: No MCMC sample will be created when n.iter is set to 0.
## 
## Call:
## lm_imp(formula = y ~ x, data = tibble(y = rnorm(100), x = c(rnorm(99), 
##     NA)) %>% as.data.frame())
## 
## (The object does not contain an MCMC sample.)
@johnsonra
Copy link
Author

I think the issue stems from line 191 of helpfunctions_checks.R - probably because indexing a tibble in this way returns a tibble with one variable, rather than a vector.

Modifying line 191 as follows seems to resolve the error:

data[is.nan(unlist(data[, k])), k]

johnsonra added a commit to johnsonra/JointAI that referenced this issue Apr 27, 2023
Bug fix for passing tibbles to model_imp functions. See Issues NErler#12 and NErler#8 for details.
@npadhye
Copy link

npadhye commented Dec 22, 2023

Thanks, @johnsonra - converting tibble to data.frame helped to avoid this error.

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