title: R - Weighted counting
body: <p>I have this df </p>
  
  <pre><code> ZONA   ID_DOM   FE_DOM NO_MORAD
  1    1 00010001 15.41667        2
  2    1 00010001 15.41667        2
  3    1 00010001 15.41667        2
  4    1 00010001 15.41667        2
  5    1 00010001 15.41667        2
  6    1 00010002 15.41667        4
  ...
      99 00010994 16.68444        5 
  </code></pre>
  
  <p>Currently, I'm counting the number of <code>ID_DOM</code> using the weight variable <code>FE_DOM</code> with this code.</p>
  
  <pre><code>count(OD_2017[!duplicated(OD_2017$ID_DOM),], 
        wt = FE_DOM, 
        Zonas = ZONA,
        name = "N_domicilios")
  </code></pre>
  
  <p>which returns me</p>
  
  <pre><code>  Zonas N_domicilios
    &lt;int&gt;        &lt;dbl&gt;
  1     1        1151.
  2     2        2342.
  3     3        7100.
  4     4       12588.
  5     5        8050.
  6     6        9411.
  </code></pre>
  
  <p>However I want this data grouped by <code>NO_MORAD</code>, something like</p>
  
  <pre><code>Zonas 1Mor 2Mor ... 99Mor 
  1     50   78   ... 78
  2     x    y    ... z
  ...
  99    99   99   ... 99
  </code></pre>
  
  <p>Can anyone help me with this?
  Thanks</p>