[R] behavior of seq_along

Henrique Dallazuanna wwwhsd at gmail.com
Thu Feb 25 15:08:32 CET 2010


Because,

data[seq_along(x)]  == data[seq_along(y)],

You need this:

sum(data[length(x) + seq_along(y)])

On Thu, Feb 25, 2010 at 11:02 AM, Dale Steele <dale.w.steele at gmail.com> wrote:
> I'm trying to understand the behavior of seq_along in the following example:
>
> x <- 1:5; sum(x)
> y <- 6:10; sum(y)
>
> data <- c(x,y)
> S <- sum( data[seq_along(x)] )
> S
> T <- sum( data[seq_along(y)] )
> T
>
> Why is T != sum(y) ?
>
> ______________________________________________
> R-help at 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O



More information about the R-help mailing list