Hi everybody. I'll first explain my problem and what I'm trying to do. Admit this example: I'm working on 5 different weather stations. I have first in one file 3 of these 5 weather stations, containing their data. Here's an example of this file:
DF1 <- data.frame(station=c("ST001","ST004","ST005"),data=c(5,2,8)) And my two other stations in this other data.frame: DF2 <- data.frame(station=c("ST002","ST003"),data=c(3,7)) I would like to add geographical coordinates of these weather stations inside these two data.frames, according to the number of the weather station. All of my geographical coordinates for each of the 5 weather stations are inside another data frame: DF3 <- data.frame(station=c("ST001","ST002","ST003","ST004","ST005"),lat=c(40,41,42,43,44),lon=c(1,2,3,4,5)) My question is: how can I put automatically these geographical coordinates inside my first 2 data frames, according to the number of the weather station? For this example, the first two data frames DF1 and DF2 should become: DF1 <- data.frame(station=c("ST001","ST004","ST005"),lat=c(40,43,44),lon=c(1,4,5),data=c(5,2,8)) and DF2 <- data.frame(station=c("ST002","ST003"),lat=c(41,42),lon=c(2,3),data=c(3,7)) I need to automatize this method because my real dataset contains 70 weather stations, and each file contains other (or same sometimes) stations , but each station can be found in the list of the coordinates file (DF3). Is there any way or any function able to do this kind of thing? Thank you very much! -- View this message in context: http://r.789695.n4.nabble.com/duplicate-data-between-two-data-frames-according-to-row-names-tp4636845.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.