Maybe you could discuss in words what you want but perhaps
you are looking for diff:
> bp <- c(0, 250, 800, 1200)
> diff(bp)
[1] 250 550 400
On 4/19/06, Paul Roebuck <roebuck at mdanderson.org>
wrote:> Isn't there a builtin method for doing this and, if so,
> what is it called?
>
> breakdown <- function(whole) {
> breaks <- c(250, 800)
> pieces <- integer(length(breaks) + 1)
> if (whole > breaks[2]) {
> pieces[3] <- whole - breaks[2]
> whole <- breaks[2]
> }
> if (whole > breaks[1]) {
> pieces[2] <- whole - breaks[1]
> whole <- breaks[1]
> }
> pieces[1] <- whole
>
> return(pieces)
> }
>
> breakdown(1200) # 250 550 400
>
> ----------------------------------------------------------
> SIGSIG -- signature too long (core dumped)
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
>