richarddmorey / BayesFactor

BayesFactor R package for Bayesian data analysis with common statistical models.
https://richarddmorey.github.io/BayesFactor/
132 stars 49 forks source link

error with tbl_df #67

Closed fdabl closed 7 years ago

fdabl commented 8 years ago

hi there,

it seems the functions lmBF, ttestBF, etc. do not working with an object of class "tbl_df" from the dplyr package.

library('dplyr')
library('BayesFactor')

dat = data.frame(y = rnorm(100), x = rnorm(100))
lmBF(y ~ x, data = tbl_df(dat)) # errors

The error is "Dependent variable must be numeric", which is especially confusing. On another occasion, I got

Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘compare’ for signature ‘"BFlinearModel", "missing", "tbl_df"’

which is when I realized the issue. I think it should work for tbl_df's too, since that is what many people's new data.frame is.

kind regards, Fabian

ps.: I was wondering how far you guys are with implementing generalized linear models. Any updates? :)

richarddmorey commented 8 years ago

mmm, yes, this is a good idea. I don't know why it doesn't just work, but I can look into it.

richarddmorey commented 8 years ago

What if I just converted back to a normal data.frame before analysis? I don't use tbl_df - what would be lost?

fdabl commented 8 years ago

I think that would be a neat solution. The only difference in tbl_df is that it only prints the first few rows and columns, and indexing does not simplify but returns a data.frame.

richarddmorey commented 8 years ago

ok, great. I'll do that then.