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

drop_rendudant_dims() issues error with data.table #431

Closed
mespe opened this issue Apr 22, 2020 · 1 comment
Closed

drop_rendudant_dims() issues error with data.table #431

mespe opened this issue Apr 22, 2020 · 1 comment

Comments

@mespe
Copy link

mespe commented Apr 22, 2020

Summary:

When a data.table is provided as data, the internal function drop_redundant_dims() results in error.

Description:

When a data.table is provided to rstanarm as data, the following error is produced:

Called from: stop("j (the 2nd argument inside [...]) is a single symbol but column name '", 
    jsubChar, "' is not found. Perhaps you intended DT[, ..", 
    jsubChar, "]. This difference to data.frame is deliberate and explained in FAQ 1.1.")

This is because the method dispatch for [ is finding the method for data.table before data.frame.

Since the error message states this is intentional for data.tables, a check and/or coercion to data.frame might be warranted.

Reproducible Steps:

library(rstanarm)
library(data.table)
mt = as.data.table(mtcars)
stan_glm(mpg ~ cyl, data = mt)

RStanARM Version:

2.19.3

R Version:

3.6.3

Operating System:

Arch Linux 5.6.5-1

@danschrage
Copy link
Contributor

I hit this same issue today, and I've submitted a pull request #434 to fix this.

I tested it on my own data and on the reproducible example above. See more detail in the PR about why it's safe to do this.

@jgabry jgabry closed this as completed in 2ab134f May 13, 2020
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