0

I'm trying to rearrange a dataframe with two variables so that each date for each identifier is in subsequent order, and then I want to pad the missing 10 months between them. It looks like this:

Date       LPERMNO
  <date>       <dbl>
1 1962-06-01   10225
2 1962-06-01   10233
3 1962-06-01   11164
4 1962-06-01   12079
5 1962-06-01   12706
....
2019-05-01   90805
2 2019-05-01   90806
3 2019-05-01   91822
4 2019-05-01   92536
5 2019-05-01   92602
6 2019-05-01   92778

I have tried:

`MagicPort3 <- MagicPort3 %>%
  group_by(Date) %>%
  arrange(LPERMNO) %>%
  group_by(LPERMNO) %>%
  arrange(Date)`

and then padding by month

but I can never get them to be in clean order. It is supposed to look like this: Ordered Dataframe

Thanks

Noe Kahn
  • 1
  • 1
  • 3
    you really need to create a MRE in your question. Right now, I cannot see the connection between your desired output and your sample data... Pleae elaborate and look here for inspiration on how to create a great question: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Wimpel Oct 31 '21 at 15:16

0 Answers0