Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想使用样条(y~x)拟合我的数据,但我能找到的所有示例都使用带平滑的样条,例如lm(y~ns(x),df = _)。
我想spline()专门使用它,因为我正在使用它来进行我正在制作的情节所代表的分析。
spline()
有没有简单的方法在 ggplot 中使用 spline()?
我已经考虑过使用拟合线的骇人听闻的方法
geom_smooth(aes(x=(spline(y~x)$x, y=spline(y~x)$y))
但我宁愿不必诉诸于此。
谢谢!
这是你想要的吗?
n <- 10 d <- data.frame(x = 1:n, y = rnorm(n)) ggplot(d,aes(x,y)) + geom_point() + geom_line(data=data.frame(spline(d, n=n*10)))