[R] ggplot2 stat_smooth
David Winsemius
dwinsemius at comcast.net
Thu Jun 30 00:10:29 CEST 2016
> On Jun 29, 2016, at 2:17 PM, Nathan Pace <n.l.pace at utah.edu> wrote:
>
> I want to add a logistic plot to data.
>
> My call to ggplot is:
>
>
> ggplot(data = SSI.dt, aes(x = elapsed, y = 1 - control)) + geom_point() +
> stat_smooth(method = 'glm', family = binomial) +
> xlab('Surgery Duration (min)') + ylab('Probability SSI') +
> labs(title = 'THA Surgical Site Infections')
> ggsave(filename = 'Plots/SSI.Duration.pdf’)
>
> An error message is returned: Unknown parameters: family
So you would have naturally looked at the acceptable arguments for the function, right?
>
> Removing “family = binomial” returns a straight line with points appropriately placed on y = 0 and y = 1.
>
> I found some previous messages on markmail that listed my call as the correct syntax structure.
Perhaps they referred to older versions of the function.
Looking at:
?stat_smooth
The current help page implements this by creating a helper function, binomial_smooth, but using its example of the needed arguments I did just try:
... + stat_smooth(method = 'glm', method.args = list(family = "binomial"))
With success.
--
David.
>
> I’d appreciate thoughts/pointers.
>
>
> Nathan
>
> --
> Nathan Pace, MD, MStat
> Department of Anesthesiology
> University of Utah
> 801.581.6393
> n.l.pace at utah.edu
>
>
>
>
>
>
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
David Winsemius
Alameda, CA, USA
More information about the R-help
mailing list