Have a look at match and merge.
Hadley
On Wednesday, September 8, 2010, Michael Haenlein
<haenlein at escpeurope.eu> wrote:> Dear all,
>
> I'm working with two data frames.
>
> The first frame (agg_data) consists of two columns. agg_data[,1] is a
unique
> ID for each row and agg_data[,2] contains a continuous variable.
>
> The second data frame (geo_data) consists of several columns. One of these
> columns (geo_data$ZCTA) corresponds to the unique ID in the first data
> frame. The problem is that only a subset of the unique ID present in the
> first data frame also appears in the second data fame.
>
> What I would like to do is to add another column to the second data frame
> (geo_data) that includes the value of the continuous variable from the
first
> frame that corresponds to the unique ID. To put it differently, I want R to
> look at each row in the second data frame, look for the unique ID
> (geo_data$ZCTA), look for the same unique ID in the first data frame and
> then paste the value from the continous variable as a new column into the
> second data frame. I hope I'm somewhat clear here ...
>
> Is there a convenient way of doing this?
>
> Thanks very much in advance,
>
> Michael
>
> ? ? ? ?[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/