Is it possible to select model parameters for a model after calling ggplot stat_smooth?

Using stat_smooth

, I can fit the models to the data. E.G.

g=ggplot(tips,aes(x=tip,y=as.numeric(unclass(factor(tips$sex))-1))) +facet_grid(time~.) 
g=g+ stat_summary(fun.y=mean,geom="point") 
g=g+ stat_smooth(method="glm", family="binomial")

      

I would like to know the glm binomial match factors. I could re-fit with dlply

and get the coefficients with ldply

, but I would like to avoid this duplication.

The call str(g)

reveals the hierarchy of objects it creates ggplot2

, perhaps there is some way to get to the coefficients through this?

+3


a source to share


1 answer


No, because the models are only created when the graph is rendered. However, it's usually pretty easy to do it yourself with plyr

.



Why do you want to convert sex to number? Usage as.numeric

should be sufficient on its own, but if you are going to do subtraction in the model, you need to surround it I()

.

+3


a source







All Articles