merge - Merging a data frame and a lookup table in r, retaining all records from data frame -


Do I have 59720 object data frame it looks like down I assign a MARKETNAME for each observation lookup table Want to

& gt; Data (a)

  day this hour Lead Row.Count DATE iTime Homephone City State ZIPCODE ZONENAME 1 Monday 13:00 1 9430 2013/07/01 13:42:51 Fort Lauderdale FL 33315 68 2 Monday 13:00 1 9432 7/1/2013 13:43:50 PLEASANT GROVE al xxxxx9802x 35127 82 3 Monday 13:00 1 9434 7/1/2013 13:46:18 5xxxx85x10 Oro Valley, AZ 85737 54 4 Monday 0:00 1 9435 7/1/2013 0:04:34 50xxxx1x364 Spokane WA 99204 211 5 Monday 11:00 1 9436 7/1/2013 11:45:43 951xxxxx20 RIVERSIDE CA 92507 31 6 Monday 11:00 1 9437 2013/07/01 11:46:26 760xxxxx679 Vista CA 92081 539  

I have a lookup table of zip codes with 43126 looks like this is the unique PIN code:

& gt; ; Data (b)

  MARKETNAME ZIPCODE New York 00501 New York 00544 Springfield-Holyoke 01001 Springfield-Holyoke 01002 Springfield-Holyoke 01003 Springfield-Holyoke 01004  

I just wanted to assign MARKETNAME to my dataset "a" in ZIPCODE to compare "b" . That's why I

& gt; C & lt; - Merge (A, B, By = "Zipcode") .

This returned 58,972 objects which means that I lost 748 objects I did not want to lose any record from a so I changed my code as follows:

& gt; C & lt; - Merge (A, B, By = "ZIPCODE", all.x = TRUE) . The

Strange it has 61,652 objects returned rather than what I expected, which was returned 59,720 objects as the original a data frame with a NAS

Documents Accordingly,

"If true, extra lines will be added to the output, for each line of x that is not a matching line in y, these rows are those columns that are generally But y is filled with values ​​from nas in. Default is wrong, h That is, only rows with data from both x and y are included in the production. "

My interpretation about this is definitely wrong, can someone please explain what I am doing And how can I complete this simple task?

I gave the reference: ..., but none of them conform to my problem.

The default in the first data frame returns to all matches of the records, one left-fold.

c & lt; - Join (a, b, by = "ZIPCODE")


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -