<div>Seria isso?</div><br><div>library(dplyr)</div><br><div>dfp21?<-structure(list(p21 = structure(c(2L, 2L, 1L, 2L, 2L, 2L, 2L, </div><div>2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, </div><div>2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, </div><div>2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, </div><div>2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, </div><div>2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, </div><div>2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, </div><div>1L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, </div><div>2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("8", "9"), class = "factor"), </div><div>    deficiencias = structure(c(7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, </div><div>    7L, 7L, 7L, 7L, 7L, 7L, 7L, 6L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, </div><div>    5L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, </div><div>    4L, 4L, 4L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, </div><div>    3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, </div><div>    3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, </div><div>    3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, </div><div>    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, </div><div>    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L), .Label = c("AH/S", </div><div>    "DA/S", "DF", "DV", "NE", "SCe", "TEA"), class = "factor")), class = "data.frame", row.names = c(NA, </div><div>-127L))</div><br><br><br><div>dfp21%>%group_by(deficiencias,p21)%>%summarize(Contagem = length(p21) )</div><br><br><div class="gmail_quote_attribution">On Feb 14 2022, at 4:58 pm, Sergio Pinto por (R-br) <r-br@listas.c3sl.ufpr.br> wrote:</div><blockquote><div><div class="gmail_default"><font style="font-family:monospace, monospace"> Prezados</font></div><div class="gmail_default"><font style="font-family:monospace, monospace">Tenho um data-frame (dfp21) com duas variáveis, a primeira variável,  chamada Deficiências, é categórica com sete níveis ('TEA', 'SCe', 'NE', 'DV', 'DF', 'DA/S', 'AH/S') a segunda, chamada p21, também é categórica com dois níveis ("8" e "9").</font></div><div class="gmail_default"><div><font style="font-family:monospace, monospace"> Coloquei os dados em anexo. Não consegui usar o DATAFILEHOST.</font></div></div><div class="gmail_default"><code><pre style="background-color:rgba(0,0,0,0.05);padding:0.2em 1em"><div><font style="font-family:monospace, monospace"><font style="font-size:16px"><font style="font-family:"Ubuntu Mono", monospace"><span style="color:blue">> dfp21</span></font></font></font></div><div><font style="font-family:monospace, monospace"><font style="font-size:16px"><font style="font-family:"Ubuntu Mono", monospace"><span style="color:blue"># A tibble: 127 × 2</span></font></font></font></div><div><font style="font-family:monospace, monospace"><font style="font-size:16px"><font style="font-family:"Ubuntu Mono", monospace"><span style="color:blue">   p21   DEFICIÊNCIAS</span></font></font></font></div><div><font style="font-family:monospace, monospace"><font style="font-size:16px"><font style="font-family:"Ubuntu Mono", monospace"><span style="color:blue">   <fct> <fct>       </span></font></font></font></div><div><font style="font-family:monospace, monospace"><font style="font-size:16px"><font style="font-family:"Ubuntu Mono", monospace"><span style="color:blue"> 1 9     TEA         </span></font></font></font></div><div><font style="font-family:monospace, monospace"><font style="font-size:16px"><font style="font-family:"Ubuntu Mono", monospace"><span style="color:blue"> 2 9     TEA         </span></font></font></font></div><div><font style="font-family:monospace, monospace"><font style="font-size:16px"><font style="font-family:"Ubuntu Mono", monospace"><span style="color:blue"> 3 8     TEA         </span></font></font></font></div><div><font style="font-family:monospace, monospace"><font style="font-size:16px"><font style="font-family:"Ubuntu Mono", monospace"><span style="color:blue"> 4 9     TEA         </span></font></font></font></div><div><font style="font-family:monospace, monospace"><font style="font-size:16px"><font style="font-family:"Ubuntu Mono", monospace"><span style="color:blue"> 5 9     TEA         </span></font></font></font></div><div><font style="font-family:monospace, monospace"><font style="font-size:16px"><font style="font-family:"Ubuntu Mono", monospace"><span style="color:blue"> 6 9     TEA         </span></font></font></font></div><div><font style="font-family:monospace, monospace"><font style="font-size:16px"><font style="font-family:"Ubuntu Mono", monospace"><span style="color:blue"> 7 9     TEA         </span></font></font></font></div><div><font style="font-family:monospace, monospace"><font style="font-size:16px"><font style="font-family:"Ubuntu Mono", monospace"><span style="color:blue"> 8 9     TEA         </span></font></font></font></div><div><font style="font-family:monospace, monospace"><font style="font-size:16px"><font style="font-family:"Ubuntu Mono", monospace"><span style="color:blue"> 9 9     TEA         </span></font></font></font></div><div><font style="font-family:monospace, monospace"><font style="font-size:16px"><font style="font-family:"Ubuntu Mono", monospace"><span style="color:blue">10 9     TEA         </span></font></font></font></div><div><font style="font-family:monospace, monospace"><font style="font-size:16px"><font style="font-family:"Ubuntu Mono", monospace"><span style="color:blue"># … with 117 more rows</span></font></font></font></div></pre></code></div><div class="gmail_default"><code><pre style="background-color:rgba(0,0,0,0.05);padding:0.2em 1em"><br></pre></code></div><div class="gmail_default"><code><pre style="background-color:rgba(0,0,0,0.05);padding:0.2em 1em"><br></pre></code></div><div class="gmail_default"><div><font style="font-family:monospace, monospace"><strong>A dúvida:</strong></font><font style="font-family:monospace, monospace"> como criar uma nova coluna com a contagem  da segunda variável em cada nível da primeira?</font></div></div><div class="gmail_default"><font style="font-family:monospace, monospace">ex: TEA 8 20</font></div><div class="gmail_default"><div><font style="font-family:monospace, monospace">    TEA 9 13</font></div></div><div class="gmail_default"><font style="font-family:monospace, monospace">    NE  8 17</font></div><div class="gmail_default"><font style="font-family:monospace, monospace">    NE  9 15 ...</font></div><div class="gmail_default"><div><font style="font-family:monospace, monospace">Estou tentando usar o dplyr para isso.</font></div></div><div class="gmail_default"><div><font style="font-family:monospace, monospace">Desde já agradeço a atenção.</font></div></div><br><div>--</div><div class="gmail_signature"><div><div><div><div><div><div><div><span style="color:rgb(0, 0, 255)"><font style="font-family:monospace, monospace"><strong>_______________________________________</strong></font></span></div></div><div><div><span style="color:rgb(0, 0, 255)"><font style="font-family:monospace, monospace"><strong>Prof. Dr. SERGIO MEDEIROS PINTO</strong></font></span></div></div><div><font style="font-family:monospace, monospace">LABICOM/IEFD-UERJ</font></div><div><font style="font-family:monospace, monospace">FAMERC-RJ</font></div><div><div><font style="font-family:monospace, monospace">UNESA-RJ</font></div></div><div><div><font style="font-family:monospace, monospace"><a href="https://link.getmailspring.com/link/5FCF0F0C-B398-482E-980B-FF4775D4BF3A@getmailspring.com/0?redirect=http%3A%2F%2Flattes.cnpq.br%2F5897044784217523&recipient=ci1ickBsaXN0YXMuYzNzbC51ZnByLmJy" title="http://lattes.cnpq.br/5897044784217523">http://lattes.cnpq.br/5897044784217523</a></font></div></div><div><br></div><div><br></div><div><br></div><div><br></div></div></div></div></div></div></div></div><div>_______________________________________________</div><div>R-br mailing list</div><div>R-br@listas.c3sl.ufpr.br</div><div>https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br</div><div>Leia o guia de postagem (http://www.leg.ufpr.br/r-br-guia) e forneça código mínimo reproduzível.</div></blockquote>