Tena koe Nilza I think merge() will do what you want. For example:
> completeDates V1 1 01-12-09 2 02-12-09 3 03-12-09 4 04-12-09 5 05-12-09 6 06-12-09 7 07-12-09 8 08-12-09 > testData V1 V2 1 01-12-09 26.8 2 03-12-09 27.9 3 04-12-09 25.6 4 05-12-09 20.8 5 08-12-09 20.8 > merge(completeDates, testData, by=1, all=T) V1 V2 1 01-12-09 26.8 2 02-12-09 NA 3 03-12-09 27.9 4 04-12-09 25.6 5 05-12-09 20.8 6 06-12-09 NA 7 07-12-09 NA 8 08-12-09 20.8 HTH ... Peter Alspach > -----Original Message----- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Nilza BARROS > Sent: Wednesday, 10 February 2010 1:30 p.m. > To: r-help@r-project.org > Subject: [R] manipulate missing dates in a graphics a vector > > Dear all, > > I am trying to identify the days absent in a vector so as to > be able to display missing data in the graphics in .It > should be done automatically since the graphics will be > generated for different periods of the year. > I have been trying to do a function below but it did not > work. I really appreciate any help > > ordados <- function(datas,var) > { > ind <- !datas %in% var # find the missing date in var miss <- > datas[ind] mat <- matrix(NA,length(miss),length(miss)) > #insert NA in the missing date mat[,1]<-miss jundado <- > rbind (mat,var) jundado <- jundado[order(jundado[,1]),] # > sort by dates } For instance: > If I have the vector below: > 2009-12-01 26.8 > 2009-12-03 27.9 > 2009-12-04 25.6 > 2009-12-05 20.8 > 2009-12-08 20.8 > I will need a result like this one > > 2009-12-01 26.8 > 2009-12-02 NA > 2009-12-03 27.9 > 2009-12-04 25.6 > 2009-12-05 20.8 > 2009-12-06 NA > 2009-12-07 NA > 2009-12-08 20.8 > > Bye and Best Regards > Nilza Barros > > [[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.