Hi, Try this: dat1<-data.frame(value=c(15,20,25,30,45,50),dates=c("2005-05-25","2005-06-25","2005-07-25","2005-08-25","2005-09-25","2005-10-25")) dat2<-data.frame(value=c(15,20,25,50),dates=c("2005-05-25","2005-06-25","2005-07-25","2005-10-25")) merge(dat1,dat2, by="dates") dates value.x value.y 1 2005-05-25 15 15 2 2005-06-25 20 20 3 2005-07-25 25 25 4 2005-10-25 50 50 or subset(dat1,(dates %in% dat2$dates)) value dates 1 15 2005-05-25 2 20 2005-06-25 3 25 2005-07-25 6 50 2005-10-25
I hope this is what you meant. You mentioned the datasets have different dimensions. Not sure what you meant. A.K. ----- Original Message ----- From: Васильченко Александр <vasilchenko....@gmail.com> To: r-help@r-project.org Cc: Sent: Tuesday, June 26, 2012 11:03 AM Subject: [R] Intersection Hello. I have a problem with 2 dataframes. There are 2 columns - "value" and "dates". These dataframes have different dimension. Some dates coincide. And I need to intersect them by dates and have on output two dataframes with identical columns "dates" and new dimension . "value" have to recieve in compliance with dates. Regards, Aleksander. [[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.