Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Sequence of sequences with increasing start in R

I am searching for a simple and elegant (basic R functions, no for cyclus) mechanism as function(start:stop) which would create, for example function(2:5) the following vector sequence:

c(2:5, 3:5, 4:5, 5:5)

2,3,4,5,3,4,5,4,5,5

I have tried to put this into the function seq(). Sadly, function seq() does not allow for vector in the argument: from=....

Do you know some solution?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thank you very much

>Solution :

We may use rep

x1 <- 2:5 + rep(0:3, each = 4)
x1[x1 <6]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading