dplyr get rowwise() sequence from start and end.

I would like to get the sequence of numbers from the start and end positions of each row:


df <- data.frame(
  start = c(1,5,7,9,10),
  end = c(2,10,17,18,20)

#I tried
  df <- df %>%
  rowwise() %>%
    seq = list(seq(start, end))
#But I get the below Error
#Fehler in seq.default(start, end) : 'from' must be of length 1

#If I just add numbers it works fine
df <- df %>%
  rowwise() %>%
    seq = list(seq(1,5))
start   end seq      
  <dbl> <dbl> <list>   
1     1     2 <int [5]>
2     5    10 <int [5]>
3     7    17 <int [5]>
4     9    18 <int [5]>
5    10    20 <int [5]>

How do I generate sequences using the start and end values for each row?

This does not error on my machine.
What version of dplyr are you using ?


I have version 1.0.3

Hmm... I updated to version 1.0.5 and the error is gone. Thanks a lot :slight_smile:

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.