[R] duplicate data between two data frames according to row names

arun smartpink111 at yahoo.com
Wed Jul 18 14:29:03 CEST 2012


You could use "merge", "join" etc.
 # station lat lon data
#1   ST002  41   2    3
#2   ST003  42   3    7
Joining by: station
#  station lat lon data
#1   ST002  41   2    3
#2   ST003  42   3    7


Hope this helps

----- Original Message -----
From: jeff6868 <geoffrey_klein at etu.u-bourgogne.fr>
To: r-help at r-project.org
Sent: Wednesday, July 18, 2012 4:21 AM
Subject: [R] duplicate data between two data frames according to row names

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

All of my geographical coordinates for each of the 5 weather stations are
inside another data frame:

DF3 <-

My question is: how can I put automatically these geographical coordinates
inside my first 2 data frames, according to the number of the weather

For this example, the first two data frames DF1 and DF2 should become:

DF1 <-
DF2 <-

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 at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list