Here's an approach using a dplyr
pipe and nesting:
library(tidyverse)
df %>%
# Need to operate by row, so group by row number
group_by(r=row_number()) %>%
# Create nested list column containing the sequence for each pair of Start, End values
mutate(custom = list(Start:End)) %>%
# Remove the row-number column, which is no longer needed
ungroup %>% select(-r) %>%
# Unnest the list column to get the desired "long" data frame
unnest()
Start End custom
<dbl> <dbl> <int>
1 1 5 1
2 1 5 2
3 1 5 3
4 1 5 4
5 1 5 5
6 6 10 6
7 6 10 7
8 6 10 8
9 6 10 9
10 6 10 10
11 11 11 11
12 15 17 15
13 15 17 16
14 15 17 17
Another option is to create a vectorized helper function that inherently operates by row:
fnc = Vectorize(function(x,y) x:y)
df %>%
mutate(custom = fnc(Start, End)) %>%
unnest()