R - Generate a sequence of numbers -


i trying create sequences of number of 6 cases, 144 cases intervals.

like 1 example

c(1:6, 144:149, 288:293)  1   2   3   4   5   6 144 145 146 147 148 149 288 289 290 291 292 293 

how generate automatically such sequence

seq  

or function ?

i find sequence function helpful in case. if had data in structure this:

(info <- data.frame(start=c(1, 144, 288), len=c(6, 6, 6))) #   start len # 1     1   6 # 2   144   6 # 3   288   6 

then in 1 line with:

sequence(info$len) + rep(info$start-1, info$len) #  [1]   1   2   3   4   5   6 144 145 146 147 148 149 288 289 290 291 292 293 

note solution works if sequences you're combining different lengths.


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -