dtkaplan / statisticalModeling

Other
11 stars 16 forks source link

gf_abline() requires an odd formula to set aesthetics #14

Closed rpruim closed 7 years ago

rpruim commented 7 years ago

This works:

> gf_point(mpg ~ hp + color:cyl + size:wt, data = mtcars) %>%
+   gf_abline(~ hp + color:"red", slope = -0.10, intercept = 35)

hp can be anything that doesn't lead to "object not found", but it isn't actually used. It would be nicer if either enquoting happened when doing color = "red" or the formula could be given as ~ color:"red" to avoid the kludge above.

dtkaplan commented 7 years ago

This should be an easy fix. It will be much more motivating to make such fixes to know that there is at least one other person in the universe who's interested in using the functions.

On Tue, Feb 21, 2017 at 4:15 PM, Randall Pruim notifications@github.com wrote:

This works:

gf_point(mpg ~ hp + color:cyl + size:wt, data = mtcars) %>%+ gf_abline(~ hp + color:"red", slope = -0.10, intercept = 35)

hp can be anything that doesn't lead to "object not found", but it isn't actually used. It would be nicer if either enquoting happened when doing color = "red" or the formula could be given as ~ color:"red" to avoid the kludge above.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/dtkaplan/statisticalModeling/issues/14, or mute the thread https://github.com/notifications/unsubscribe-auth/AAggrdrafwlqgT114l2ws8xHaKzPJVDOks5re2H-gaJpZM4MH77Y .

--

...

DeWitt Wallace Professor of Mathematics, Statistics, and Computer Science Macalester College

rpruim commented 7 years ago

It was indeed easy. Just had to add an additional case where the formula has neither y nor x defined. Also, I changed the cascading ifelse to a switch().

Stay tuned for full request.