I have a dataframe
dat <- data.frame(c("G", "G", "G", "G"), c("G1", "G1", "G2", "G2"), c('2017-01-01', '2017-01-03', '2017-04-02', '2017-04-05'))
colnames(dat) <- c('Country', 'Place', 'date')
I would like to have this output: (complete date for each (country-place) group)
dat <- data.frame(c("G", "G", "G", "G", "G", "G", "G"),
c("G1","G1", "G1", "G2", "G2", "G2", "G2"),
c('2017-01-01', '2017-01-03','2017-01-03',
'2017-04-02', '2017-04-03', '2017-04-04', '2017-04-05'))
I have tried:
dat = dat %>% group_by(Country, Place) %>% complete(date)
but it does not work.
Can anyone help me with this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…