[R] Question on Merge/Lookup

Don MacQueen
Sat, 23 Jan 2010 01:00:21 -0000

Perhaps using the R merge() function, possibly twice in succession,
will do the job. (merge() does a one to many relational join, but
with only two dataframes at at time).

Or, there is an R package that lets you use the SQL language on
dataframes. I don't recall its name, but a search on R packages
should turn it up -- if someone else doesn't provide the name sooner.

-Don

At 10:52 AM -0800 1/22/10, GL wrote:
>I need to merge three datasets and don't know how. If I were using SQL,
I
>would use df3, look up the characteristics of each date in df1 and the value
>for each observation in df2.
>
>
>df1 - unique list of Dates and characteristics of those dates
>Date, YYYYMM, YYYYWW, DOW
>
>
>df2 - the raw data
>Date, Place, Value
>
>
>df3 - all posibile combinations of Date + Place (via
>expand.grid(unique(df2$Date),unique(df2$Place))
>Date, Place
>
>I need to end up with:
>
>Date, YYYYMM, YYYYWW, DOW, PLace, Value (plug 0 if combo doesn't exist
in
>raw data).
>
>Appreciate any help!
>
>
>--
>View this message in context:
>http://*n4.nabble.com/Question-on-Merge-Lookup-tp1112384p1112384.html
>Sent from the R help mailing list archive at Nabble.com.
>
>______________________________________________
>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.


--
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062