Try this. It creates a sequence of dates from the range of df$date1 and then does a setdiff between that and the original dates. The result is numeric so we create a Date structure out of it.
structure(setdiff(do.call(seq, as.list(range(df$date1))), df$date1), class = "Date") On Jan 2, 2008 1:55 AM, <[EMAIL PROTECTED]> wrote: > Hi, > > I have a data.frame like this: > > y <- rnorm(60) > lev <- gl(3,20, labels=paste("lev", 1:3, sep="")) > date1 <- as.Date(seq(ISOdate(2007,9,1), ISOdate(2007,11,5), > by=60*60*24)) > date1 <- date1[-c(3,4,15,34,38,40)] > df <- data.frame(lev=lev, date1=date1, y=y) > > I would like to produce a new data.frame with missing days in df$date1 > in each df$lev, like this: > > lev date1 > 1 lev1 2007-09-03 > 2 lev1 2007-09-04 > 3 lev1 2007-09-15 > 4 lev2 2007-09-01 > 5 lev2 2007-09-02 > etc. > > How can I do this? > > Thanks, > Lauri > FRCBS > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.