[R] behavior of seq_along

Dieter Menne dieter.menne at menne-biomed.de
Thu Feb 25 15:15:46 CET 2010



Dale Steele wrote:
> 
> 
> 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
> 
> 

If in doubt, divide and conquer:

seq_along(x)
[1] 1 2 3 4 5
> seq_along(y)
[1] 1 2 3 4 5

You expected  that the second vector is 6,7...
Dieter

-- 
View this message in context: http://n4.nabble.com/behavior-of-seq-along-tp1569033p1569049.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list