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 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 easiest way in R to get from x to y?
(Or more general; to add labels inside the bars in a stacked barplot)



thanks!

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to