Using stat_smooth
, I can fit models to data. E.g.
g=ggplot(tips,aes(x=tip,y=as.numeric(unclass(factor(tips$sex))-1))) +facet_grid(time~.)
g=g+
No, because the models are only created when the plot is rendered. However, it's usually pretty easy to do it yourself with plyr
.
Why do you want to convert sex to a number? Using as.numeric
should be enough by itself, but if you're going to do the subtraction in the model you'll need to surround it with I()
.