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

Allow dates when selecting "typical" values. #16

Open
dtkaplan opened this issue Jun 20, 2018 · 1 comment
Open

Allow dates when selecting "typical" values. #16

dtkaplan opened this issue Jun 20, 2018 · 1 comment

Comments

@dtkaplan
Copy link
Contributor

Currently, dates are treated as categorical, and so we fail to interpolate when nlevels = Inf and the result can't be handed off to evaluate.

@rpruim
Copy link
Contributor

rpruim commented Jun 23, 2018

Not sure I have fixed everything, but I've added code so that typical_values() can handle dates:

library(mosaicModel)
#> Loading required package: mosaicCore
#> Loading required package: splines
#> Loading required package: magrittr
library(mosaicData)
library(ggformula)
#> Loading required package: ggplot2
#> 
#> New to ggformula?  Try the tutorials: 
#>  learnr::run_tutorial("introduction", package = "ggformula")
#>  learnr::run_tutorial("refining", package = "ggformula")
theme_set(theme_bw())
bmod <- lm(births ~ date * wday, data = Births2015)
mod_eval(bmod, nlevels = 3)
#>         date  wday model_output
#> 1 2015-03-11 Thurs    11994.204
#> 2 2015-07-01 Thurs    12082.644
#> 3 2015-10-22 Thurs    12171.874
#> 4 2015-03-11   Sun     7254.654
#> 5 2015-07-01   Sun     7397.171
#> 6 2015-10-22   Sun     7540.962
#> 7 2015-03-11   Mon    11465.407
#> 8 2015-07-01   Mon    11735.764
#> 9 2015-10-22   Mon    12008.534
mod_plot(bmod)

gf_point(births ~ date, data = Births2015, color = ~wday) %>%
  mod_plot(bmod, nlevels = 7)

Created on 2018-06-22 by the reprex package (v0.2.0).

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