Re: [R] sequentially aggregating elements of a vector

2013-10-14 Thread Martin Batholdy
> The last element 11 in y is confusing. sorry for the typo. It is of course y <- c(1,3,6,10) > cumsum(x) thanks! On Oct 14, 2013, at 20:57 , arun wrote: > The last element 11 in y is confusing. > > cumsum(x) > [1] 1 3 6 10 > A.K. > > > On Monday, October 14, 2013 2:51 PM, Martin Bath

Re: [R] sequentially aggregating elements of a vector

2013-10-14 Thread Rui Barradas
Hello, Try ?cumsum cumsum(1:4) [1] 1 3 6 10 Hope this helps, Rui Barradas Em 14-10-2013 19:49, Martin Batholdy escreveu: Hi, for labelling the stacked bars in a barplot, I need to sequentially sum up the elements of a vector. Suppose I have; x <- c(1,2,3,4) (which correspond to the

[R] sequentially aggregating elements of a vector

2013-10-14 Thread Martin Batholdy
Hi, for labelling the stacked bars in a barplot, I need to sequentially sum up the elements of a vector. Suppose I have; x <- c(1,2,3,4) (which correspond to the bar-width of stacked bars) I need; y <- c(1,3,6,11) (which corresponds to the upper y-values for each bar). What is the eas