Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your title mentions "merge" but you seem to have not tried the <code>merge</code> function. (Or am I missing something?)</p> <p>Here are your first two example <code>data.frame</code>s:</p> <pre><code>DF1 &lt;- structure(list(T1 = c("T2", "T1", "T2", "T1", "T2", "T1", "T2" ), A1 = c("A1", "A2", "A2", "A1", "A1", "A2", "A2"), B1 = c("B1", "B1", "B1", "B2", "B2", "B2", "B2")), .Names = c("T1", "A1", "B1"), class = "data.frame", row.names = c(NA, -7L)) DF2 &lt;- structure(list(T1 = c("T1", "T2", "T1", "T2", "T2", "T2"), A2 = c("A2", "A2", "A1", "A1", "A2", "A1"), B2 = c("B1", "B1", "B1", "B2", "B2", "B1"), X1 = c(3L, 3L, 1L, 2L, 2L, 2L)), .Names = c("T1", "A2", "B2", "X1"), class = "data.frame", row.names = c(NA, -6L)) </code></pre> <p>Here's how you use <code>merge</code> from base R. The <code>by.x</code> and <code>by.y</code> arguments should include the names of the columns that you should have in common in both <code>data.frame</code>s. The <code>all</code> argument says to not drop any "blanks" but fill them with <code>NA</code> instead.</p> <pre><code>merge(DF1, DF2, by.x = c("T1", "A1", "B1"), by.y = c("T1", "A2", "B2"), all = TRUE) # T1 A1 B1 X1 # 1 T1 A1 B1 1 # 2 T1 A1 B2 NA # 3 T1 A2 B1 3 # 4 T1 A2 B2 NA # 5 T2 A1 B1 2 # 6 T2 A1 B2 2 # 7 T2 A2 B1 3 # 8 T2 A2 B2 2 </code></pre> <p>Here's the result of <code>merge</code> on the two <code>data.frame</code>s that Arun created. Notice that we don't need to specify which columns to merge on since they have common column names.</p> <pre><code>merge(df1, df2, all = TRUE) # V1 V2 V3 run.no run.no.std.rp Block.ccd A B C D # 1 T1 A1 B1 4 C0.3 0 450 120.0 8 4.000 # 2 T1 A1 B2 NA &lt;NA&gt; NA NA NA NA NA # 3 T1 A2 B1 2 C0.7 0 450 120.0 2 4.000 # 4 T1 A2 B2 1 C0.17 0 400 147.5 5 2.675 # 5 T2 A1 B1 7 C0.15 0 450 120.0 2 1.350 # 6 T2 A1 B2 5 C0.4 0 350 120.0 8 4.000 # 7 T2 A2 B1 3 C0.6 0 350 175.0 2 4.000 # 8 T2 A2 B2 6 C0.16 0 350 120.0 2 1.350 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload