title: Merging data sets with unequal observations
body: <p>I have two data sets, one is the subset of another but the subset has additional column, with lesser observations.</p>
  
  <p>Basically, I have a unique ID assigned to each participants, and then a HHID, the house id from which they were recruited (eg 15 participants recruited from 11 houses).</p>
  
  <pre><code>&gt; Healthdata &lt;- data.frame(ID = gl(15, 1), HHID = c(1,2,2,3,4,5,5,5,6,6,7,8,9,10,11))
  &gt; Healthdata
  </code></pre>
  
  <p>Now, I have a subset of data with only one participant per household, chosen who spent longer hours watching television. In this subset data, I have computed socioeconomic score (SSE) for each house.</p>
  
  <pre><code>&gt; set.seed(1)
  &gt; Healthdata.1&lt;- data.frame(ID=sample(1:15,11, replace=F), HHID=gl(11,1), SSE = sample(-6.5:3.5, 11, replace=TRUE))
  &gt; Healthdata.1
  </code></pre>
  
  <p>Now, I want to assign the SSE from the subset (Healthdata.1) to unique participants of bigger data (Healthdata) such that, participants from the same house gets the same score.</p>
  
  <p>I can't merge this simply, because the data sets have different number of observations, 15 in the bigger one but only 11 in the subset.</p>
  
  <p>Is there any way to do this in R? I am very new to it and I am stuck with this.</p>
  
  <p>I want the required output as something like below, ie ID (participants) from same HHID (house) should have same SSE score. The following output is just meant for an example of what I need, the above seed will not give the same output.</p>
  
  <pre><code> ID HHID SSE
   1    1  -6.5
   2    2  -5.5
   3    2  -5.5
   4    3   3.3
   5    4   3.0
   6    5   2.58
   7    5   2.58
   8    5   2.58
   9    6  -3.05
  10    6  -3.05
  11    7  -1.2
  12    8   2.5
  13    9   1.89
  14   10   1.88
  15   11  -3.02
  </code></pre>
  
  <p>Thanks.</p>