0

I have a dataset like this:

  ID n
1  A 4
2  B 2

And im trying to transform to this:

  new
1   A
2   A
3   A
4   A
5   B
6   B

Repeat the ID values based on the n column

I tryed pivot_longer but i didnt manage to do..

Example df:

data.frame(ID = c("A","B"),
           n = c(4,2)

)

Lucca Nielsen
  • 1,497
  • 3
  • 16

0 Answers0