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

seq() function with increasing increment steps

I want to generate a vector with the values from 13 to 79. The distance between the elements should be the index of the value itself. So that the output would be 13, 14, 16, 19, 23, 28, 34, 41, 49, 58, 68, 79
Can i accomplish this with the seq() function? Is there a way to increase the by argument with each step?

>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

With accumulate:

Reduce(`+`, 1:11, init = 13, accumulate = TRUE)
#[1] 13 14 16 19 23 28 34 41 49 58 68 79

purrr::accumulate(1:11, .init = 13, `+`)
#[1] 13 14 16 19 23 28 34 41 49 58 68 79
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