Я думаю, что функция, которую вы ищете, это cumsum()
, которая будет делать кумулятивную сумму для вектора.
#put your data into 3 vectors
x<-c(-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10)
dat1<-c(0.0140149,0.00890835,0.00672276,0.00876399,0.00806879,0.0088366,0.00856872,0.0195384,0.0160239,0.0254455,0.0397413,0.0743316,0.0247501,0.0214285,0.0241462,0.0150943,0.0141398,0.0101515,0.0308843,0.0095504,0.00729676)
dat2<-c(0.014015,0.008918,0.006725,0.008794,0.008081,0.008851,0.008578,0.019609,0.016183,0.025785,0.040091,0.075545,0.025332,0.021778,0.024497,0.015241,0.014237,0.010295,0.031294,0.009606,0.007371)
#create a new vector called cdat1 to hold the cumulative sum
cdat1<-cumsum(dat1)
plot(x,cdat1)
points(x,dat2,col="red")
Я использую функциональные точки выше, чтобы добавить dat2 к существующему графику. Запустите это в R и посмотрите, даст ли оно вам то, что вам нужно.