'Hello' || 'Goodbye'
false || 'Goodbye'
按此情节:
如何获得平滑的周期性轨迹?我尝试过的平滑函数都想制作一个平滑函数。
示例1(引发错误):
x <- sin(1:20)
y <- (dplyr::lag(x)-x)-x
plot(x, y, type="l")
示例2(绘制函数):
lines(smooth.spline(x, y))
示例3(绘制函数):
lo <- loess(y~x)
lines(predict(lo), col='red', lwd=2)
答案 0 :(得分:1)
我认为您同时要求(a)更平滑的曲线和(b)圆柱/对称圆,对吗?
增加点数以使其更平滑。固定长宽比使其成一个圆圈(即,asp=1
)。
x <- sin((1:20000) / 1000)
y <- cos((1:20000) / 1000)
plot(x, y, type="l", asp=1)
EDIT,回复OP在下面的评论。:
使用dplyr::lag()
,同时增加点数。但是,从概念上讲不要移动滞后时间(即, y 应该是 x 的1
的完整值)。
( x = 1, y = 0),( x = 1.001, y = 0.001) ,...,( x = 20, y = 19)
x <- sin((1:20000) / 1000)
y <- (dplyr::lag(x, 1000)-x)-x
plot(x, y, type="l", asp=1)
如果这不是您想要的,则可以草绘图片并附加(例如MS Paint或Inkscape)。