How can I use splne() with ggplot?

Posted by David on Stack Overflow See other posts from Stack Overflow or by David
Published on 2010-12-21T22:20:50Z Indexed on 2010/12/21 22:54 UTC
Read the original article Hit count: 244

Filed under:
|
|

I would like to fit my data using spline(y~x) but all of the examples that I can find use a spline with smoothing, e.g. lm(y~ns(x), df=_).

I want to use spline() specifically because I am using this to do the analysis represented by the plot that I am making.

Is there a simple way to use spline() in ggplot?

I have considered the hackish approach of fitting a line using

geom_smooth(aes(x=(spline(y~x)$x, y=spline(y~x)$y))

but I would prefer not to have to resort to this.

Thanks!

© Stack Overflow or respective owner

Related posts about r

    Related posts about ggplot2