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.
我有一个矢量图
v<-c(1,2,3)
我需要按以下方式在向量中添加数字
1,1+2,1+2+3
产生第二个向量
v1<-c(1,3,6)
这可能很简单......但我有点卡住了。
使用累积和函数:
cumsum(v) #[1] 1 3 6