ProjectMOSAIC / mosaicData

R package with Project MOSAIC datasets
5 stars 6 forks source link

Convert examples to ggformula? #28

Open rpruim opened 6 years ago

nicholasjhorton commented 6 years ago

Sorry I didn't think of this sooner! I agree that this would be a good idea.

rpruim commented 6 years ago

I did a bunch of conversion before submitting to CRAN. I see that this one has add = TRUE that should be deleted -- argh.

> example(GoosePermits)

GsPrmt> data(GoosePermits)

GsPrmt> goose.model <- 
GsPrmt+   glm( cbind(keep, sell) ~ log(bid), data = GoosePermits, family = binomial())

GsPrmt> if (require(ggformula)) {
GsPrmt+   y.hat <- makeFun(goose.model)
GsPrmt+   gf_point( (keep/(keep+sell)) ~ bid, data = GoosePermits, ylim = c(0,1.05)) %>%
GsPrmt+   gf_fun(y.hat(b) ~ b, add = TRUE, color = "red", alpha = 0.5) 
GsPrmt+ }
Warning: Ignoring unknown parameters: add

It's probably worth another spin through all the examples before we close this.

Here's another example.


> example(Birthdays)

Brthdy> data(Birthdays)

Brthdy> if (require(mosaic)) {
Brthdy+   MI <- Birthdays %>% filter(state == "MI")
Brthdy+   gf_point(births ~ date, Birthdays, data = MI) 
Brthdy+   gf_line(births ~ date, Birthdays, data = MI, color = ~ wday)
Brthdy+   gf_line(births ~ date, 
Brthdy+     data = Birthdays %>% group_by(date) %>% summarise(births = sum(births)))
Brthdy+   }