JointAI
JointAI copied to clipboard
Error when passing tibble
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.)
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]
Thanks, @johnsonra - converting tibble to data.frame helped to avoid this error.