Re: [R] Sequential date by group

2019-09-03 Thread Miluji Sb
Thanks, Jeff. I am trying your solutions - appreciate your help! Best, Milu On Tue, Sep 3, 2019 at 12:51 AM Jeff Newmiller wrote: > Your sample data has startdate and enddate columns as though these values > might vary throughout the data set, but your description suggests that > those values

Re: [R] Sequential date by group

2019-09-02 Thread Jeff Newmiller
Your sample data has startdate and enddate columns as though these values might vary throughout the data set, but your description suggests that those values are fixed for the whole dataset. If those values are really constant, then x$Year <- 1995L + 12 * ( ( x$month - 1L ) %/% 12L ) x$Month <

Re: [R] Sequential date by group

2019-09-02 Thread Eric Berger
dtV <- seq(from=as.Date("1975-01-01"),by='1 month',length=372) x$dt <- dtV[x$id] HTH, Eric On Mon, Sep 2, 2019 at 8:36 PM Miluji Sb wrote: > Dear all, > > I have a panel data with a large number of groups and the cumulative number > of months (1 - 372) for January 1995 to December 2005. My goa

[R] Sequential date by group

2019-09-02 Thread Miluji Sb
Dear all, I have a panel data with a large number of groups and the cumulative number of months (1 - 372) for January 1995 to December 2005. My goal is to extract the corresponding month and year for each observation. I tried the following; ### x %>% group_by(id) %>% do( data.frame(., Date=