Read them in as zoo objects (you can replace textConnection(Lines1) with the filename) and then merge them using all = FALSE to retain only common time points. Note that in my English locale I had to modify your Apl to Apr.
Lines1 <- "Date x y Jan-1,2005 120 230 Jan-2,2005 123 -125 Jan-3,2005 -110 300 Jan-4,2005 114 -21 Jan-7,2005 11 299 Mar-5,2005 200 311" Lines2 <- "Date x y Jan-2,2005 123 -125 Jan-3,2005 -110 300 Jan-4,2005 114 -21 Jan-5,2005 11 299 Jan-6,2005 -23 12 Mar-5,2005 200 311" Lines3 <- "Date x y Jan-3,2005 -110 300 Jan-4,2005 114 -21 Jan-5,2005 11 299 Mar-5,2005 200 311 Apr-23,2005 123 200" library(zoo) DF1 <- read.zoo(textConnection(Lines1), header = TRUE, format = "%b-%d,%Y") DF2 <- read.zoo(textConnection(Lines2), header = TRUE, format = "%b-%d,%Y") DF3 <- read.zoo(textConnection(Lines3), header = TRUE, format = "%b-%d,%Y") merge(DF1, DF2, DF3, all = FALSE) On 4/20/06, stat stat <[EMAIL PROTECTED]> wrote: > Dear r-users, > > Suppose I have three datasets: > Dataset-1: > Date x y > Jan-1,2005 120 230 > Jan-2,2005 123 -125 > Jan-3,2005 -110 300 > Jan-4,2005 114 -21 > Jan-7,2005 11 299 > Mar-5,2005 200 311 > > Dataset-2: > Date x y > Jan-2,2005 123 -125 > Jan-3,2005 -110 300 > Jan-4,2005 114 -21 > Jan-5,2005 11 299 > Jan-6,2005 -23 12 > Mar-5,2005 200 311 > > Dataset-3: > Date x y > Jan-3,2005 -110 300 > Jan-4,2005 114 -21 > Jan-5,2005 11 299 > Mar-5,2005 200 311 > Apl-23,2005 123 200 > Now I want to get the common dates along with x and y from this above three > datasets keeping the same order > in date-variable as it is. > For ex. I want to get: > Date x y x y > x y > (from dataset-1) (from dataset-2) (from > dataset-3) > ------------------------------------------------------------------------------------------------ > Jan-3,2005 -110 300 -110 300 -110 > 300 > Jan-4,2005 114 -21 114 -21 114 > -21 > Mar-5,2005 200 311 200 311 200 > 311 > Can anyone give me any R code to implement this for any number of datasets ? > Thanks and regards > > > thanks in advance > > --------------------------------- > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html