I have a similar question to this post: Fill in values between start and end value in R
The difference is that I need to fill in values between the start and end of multiple values and it doesn’t contain and ID column:
My data look like this (Original data have many different values) :
My final result should look like this :
Data :
structure(list(elevation = c(150L,140L, 130L, 120L, 110L, 120L, 130L, 140L, 150L, 90L, 80L, 70L,66L, 60L, 50L, 66L, 70L, 72L, 68L, 65L, 60L, 68L, 70L),code = c(NA, NA, "W", NA, NA, NA, "W", NA, NA, NA, NA, NA, "X", NA, NA, "X", NA, NA, "Y", NA, NA, "Y", NA)), class = "data.frame", row.names = c(NA,-23L))
Thanks in advance