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

create a sequence using seq() but starting at a number other than one and

I want to create a sequence starting at 10 and that sequence be the length of a vector.

length(myVec) = 3

seq(length(myVec), 10)

However my issue here is that the sequence counts down from 10 to 3 whereas I need it to do from 10 to 12, which is the length of myVec, like so;

seq(length(myVec), 10)
10, 11, 12

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

>Solution :

Lots of ways to solve this, but here’s one:

> seq(from = 10, length.out = 3)
[1] 10 11 12

You can obviously change the hardcoded values to variables to better fit your use case.

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