I have a data frame with thousands of rows, similar to:
set.seed(1)
df = data.frame(ID=c(1:10),
from=c(sort(runif(10, min=1000, max=10000))),
to=c(sort(runif(10, min=5000, max=20000))))
In this data frame I have a range (from-to), and I need some intermediate values, it could be a number every 1000 units. The desired output is a data frame with the ID column and a row for each value in the range, like:
ID number
1 1556.076
1 2556.076
1 3556.076
1 4556.076
1 5556.076
1 6556.076
1 7556.076
1 7648.351 # From column "to"
2 2815.137
2 3815.137
2 4815.137
2 5815.137
2 6815.137
2 7815.137
2 8089.619 # From column "to"
# And so on…
Can anybody help? I've been trying in several different ways, but couldn't figure out an effective way to do that.
Thanks in advance!