[R] How do you generate multiple sequences

Uwe Ligges ligges at statistik.uni-dortmund.de
Thu Dec 23 09:05:29 CET 2004


Mulholland, Tom wrote:

> I thought it would be quite simple to generate a number of sequences, but my only answer is to loop and this doesn't seem in keeping with R's capabilities.
> 
> In short I have the start and finish positions of several (well thousands probably) sequences. So I am looking at how do I take
> 
> x <- c(2,6,13,20)
> y <- c(4,10,16,24)
> 
>  and produce a list with four components with the appropriate sequence
> 
> Something like
> [[1]]
> [1] 2 3 4
> 
> [[2]]
>  [1] 6 7 8 9 10
> 
> [[3]]
>  [1] 13 14 15 16
> 
> [[4]]
>  [1] 20 21 22 23 24
> 
> So can someone point me in the direction of the ******* obvious

See ?seq and ?mapply:

mapply(seq, x, y)


Uwe Ligges



> 
> 
> Tom Mulholland
>          _              
> platform i386-pc-mingw32
> arch     i386           
> os       mingw32        
> system   i386, mingw32  
> status                  
> major    2              
> minor    0.0            
> year     2004           
> month    10             
> day      04             
> language R
> 
> ______________________________________________
> 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




More information about the R-help mailing list