如何在基础 R 中创建累积和图?
要在基础 R 中创建累积和图,我们可以简单地使用 plot 函数。要让累积和显示在图中,需要对要累加求和的变量使用 cumsum 函数。例如,如果我们有两个变量,比如 x 和 y,那么带有累积和图的图可以这样创建:plot(x,cumsum(y))。
示例
x1<--10:10 y1<-rnorm(21,5,0.324) plot(x1,cumsum(y1))
输出
Explore our latest online courses and learn new skills at your own pace. Enroll and become a certified expert to boost your career.
示例
x2<-1:20 y2<-rpois(20,5) plot(x2,cumsum(y2))
输出
广告