From stairstep vector to linear vector

Hi to everybody, i'm new about Rstudio since ì have been using this software only for few months.
I have a function like this
1 150
3 200
7 300
...
and i wish to transform it in
1 150
2 200
3 200
4 200
5 300
6 300
7 300
8 300
9 300
10 300
....
to perform a linear regression.
I'm thinking about to use a simple for...next cicle to get it, but there is a more elegant way you know?
Thanks in advance for any help
Luca

library(tidyverse)
(example_start <- tribble(
~reps,~val,
1, 150,
3, 200,
7, 300))

(result <- example_start %>% uncount(weights = reps))

Thank you very much, it works great.
Luca

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.