<div dir="ltr"><div class="gmail_default" style="font-family:courier new,monospace;color:#000066">Leandro,</div><div class="gmail_default" style="font-family:courier new,monospace;color:#000066"><br></div><div class="gmail_default" style="font-family:courier new,monospace;color:#000066">
Não tenho certeza se entendi certo o seu problema. Se for pra fazer uma tabela empilhada de diversas variáveis (na linhas) po ruma única variável nas colunas, então a função é epicalc::tableStack</div><div class="gmail_default" style="font-family:courier new,monospace;color:#000066">
<br></div><div class="gmail_default" style="font-family:courier new,monospace;color:#000066">Abraço,</div></div><div class="gmail_extra"><br clear="all"><div><div dir="ltr"><font face="'courier new', monospace" style="background-color:rgb(255,255,255)" color="#000066">Dr. Pedro Emmanuel A. A. do Brasil</font><div>
<span style="color:rgb(0,0,102);font-family:'courier new',monospace"><a href="http://blog.ipec.fiocruz.br/lapclin-chagas/" target="_blank">http://blog.ipec.fiocruz.br/lapclin-chagas/</a></span><font face="'courier new', monospace" style="background-color:rgb(255,255,255)" color="#000066"><br>
</font></div><div><font face="'courier new', monospace" style="background-color:rgb(255,255,255)" color="#000066">Curriculum Lattes:
<span style="text-align:left"><a href="http://lattes.cnpq.br/6597654894290806" target="_blank">http://lattes.cnpq.br/6597654894290806</a></span></font></div><div><font face="'courier new', monospace" style="background-color:rgb(255,255,255)" color="#000066">ResearchGate.net: <a href="https://www.researchgate.net/profile/Pedro_Brasil2/" target="_blank">https://www.researchgate.net/profile/Pedro_Brasil2/</a><br>
</font></div><div><span style="color:rgb(0,0,102);font-family:'courier new',monospace">Instituto Nacional de Infectologia/Instituto de Pesquisa Clínica Evandro Chagas</span><br></div><div><font face="'courier new', monospace" style="background-color:rgb(255,255,255)" color="#000066">Fundação Oswaldo Cruz<br>
Rio de Janeiro - Brasil<br>Av. Brasil 4365, <br>CEP 21040-360,<br>Tel 55 21 3865-9648<br>e-mail: <a href="mailto:pedro.brasil@ipec.fiocruz.br" target="_blank">pedro.brasil@ipec.fiocruz.br</a><br>e-mail: <a href="mailto:emmanuel.brasil@gmail.com" target="_blank">emmanuel.brasil@gmail.com</a><br>
</font></div></div></div>
<br><br><div class="gmail_quote">Em 31 de julho de 2014 12:00, Leandro Marino <span dir="ltr"><<a href="mailto:leandromarino@leandromarino.com.br" target="_blank">leandromarino@leandromarino.com.br</a>></span> escreveu:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif;font-size:small;color:rgb(51,51,51)">
Caros,</div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif;font-size:small;color:rgb(51,51,51)">
<br></div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif;font-size:small;color:rgb(51,51,51)">rotineiramente me deparo com um problema que não sei como resolver. Considerem o seguinte exemplo:</div>
<div class="gmail_default" style="font-family:'trebuchet ms',sans-serif;font-size:small;color:rgb(51,51,51)"><br></div><div class="gmail_default"><div class="gmail_default"><span style="color:rgb(51,51,51);font-family:'trebuchet ms',sans-serif">(c1 <- trunc(runif(1000,1,10)))</span><br>
</div><div class="gmail_default"><font color="#333333" face="trebuchet ms, sans-serif">(c2 <- trunc(runif(1000,5,70)))</font></div><div class="gmail_default"><font color="#333333" face="trebuchet ms, sans-serif">(c3 <- trunc(runif(1000,1,4)))</font></div>
<div class="gmail_default"><font color="#333333" face="trebuchet ms, sans-serif">(var <- rnorm(1000,10,2))</font></div><div class="gmail_default"><font color="#333333" face="trebuchet ms, sans-serif">(peso <- round(rnorm(1000,1,.2)^2,1))</font></div>
<div class="gmail_default"><font color="#333333" face="trebuchet ms, sans-serif">df <- data.frame(c1,c2,c3,var,peso)</font></div><div class="gmail_default"><font color="#333333" face="trebuchet ms, sans-serif"><br>
</font></div><div class="gmail_default"><font color="#333333" face="trebuchet ms, sans-serif"><br></font></div><div class="gmail_default"><font color="#333333" face="trebuchet ms, sans-serif">Gostaria de uma função que pudesse me fornecer em uma única tabela do tipo</font></div>
<div class="gmail_default"><font color="#333333" face="trebuchet ms, sans-serif">cols = c1,c2,c3,count,medvar</font></div><div class="gmail_default"><font color="#333333" face="trebuchet ms, sans-serif">e, mais genericamente,</font></div>
<div class="gmail_default"><div class="gmail_default"><font color="#333333" face="trebuchet ms, sans-serif">cols = c1,c2,c3,somapeso,medpondvar</font></div><div class="gmail_default"><font color="#333333" face="trebuchet ms, sans-serif"><br>
</font></div><div class="gmail_default"><font color="#333333" face="trebuchet ms, sans-serif">com todas as combinações existentes (as vezes todas as teoricamente possiveis) entre c1,c2,c3</font></div><div class="gmail_default">
<font color="#333333" face="trebuchet ms, sans-serif">c1</font></div><div class="gmail_default"><font color="#333333" face="trebuchet ms, sans-serif">c2</font></div><div class="gmail_default"><font color="#333333" face="trebuchet ms, sans-serif">c3</font></div>
<div class="gmail_default"><font color="#333333" face="trebuchet ms, sans-serif">c1*c2</font></div><div class="gmail_default"><font color="#333333" face="trebuchet ms, sans-serif">c1*c3</font></div><div class="gmail_default">
<font color="#333333" face="trebuchet ms, sans-serif">c2*c3</font></div><div class="gmail_default"><font color="#333333" face="trebuchet ms, sans-serif">c1*c2*c3</font></div><div class="gmail_default"><font color="#333333" face="trebuchet ms, sans-serif"><br>
</font></div><div class="gmail_default"><font color="#333333" face="trebuchet ms, sans-serif">De forma mais específica, gostaria:</font></div><div class="gmail_default"><font color="#333333" face="trebuchet ms, sans-serif"><div class="gmail_default">
<br></div><div class="gmail_default">t1 <- aggregate(list(count = df$var), list(c1=rep('*tot',1000) ,c2=rep('*tot',1000),c3=rep('*tot',1000)),length)</div><div class="gmail_default">tc1 <- aggregate(list(count = df$var), list(c1=df$c1 ,c2=rep('*tot',1000),c3=rep('*tot',1000)),length)</div>
<div class="gmail_default">tc2 <- aggregate(list(count = df$var), list(c1=rep('*tot',1000),c2=df$c2 ,c3=rep('*tot',1000)),length)</div><div class="gmail_default">tc3 <- aggregate(list(count = df$var), list(c1=rep('*tot',1000),c2=rep('*tot',1000),c3=df$c3 ),length)</div>
<div class="gmail_default">tc1c2 <- aggregate(list(count = df$var), list(c1=df$c1 ,c2=df$c2 ,c3=rep('*tot',1000)),length)</div><div class="gmail_default">tc1c3 <- aggregate(list(count = df$var), list(c1=df$c1 ,c2=rep('*tot',1000),c3=df$c3 ),length)</div>
<div class="gmail_default">tc2c3 <- aggregate(list(count = df$var), list(c1=rep('*tot',1000),c2=df$c2 ,c3=df$c3 ),length)</div><div class="gmail_default">tc1c2c3 <- aggregate(list(count = df$var), list(c1=df$c1 ,c2=df$c2 ,c3=df$c3),length)</div>
<div class="gmail_default">comp1 <- rbind(t1,tc1,tc2,tc3,tc1c2,tc1c3,tc2c3,tc1c2c3)</div><div class="gmail_default">rm(t1,tc1,tc2,tc3,tc1c2,tc1c3,tc2c3,tc1c2c3)</div><div class="gmail_default"><br></div><div class="gmail_default">
t1 <- aggregate(list(medvar = df$var), list(c1=rep('*tot',1000) ,c2=rep('*tot',1000),c3=rep('*tot',1000)),mean)</div><div class="gmail_default">tc1 <- aggregate(list(medvar = df$var), list(c1=df$c1 ,c2=rep('*tot',1000),c3=rep('*tot',1000)),mean)</div>
<div class="gmail_default">tc2 <- aggregate(list(medvar = df$var), list(c1=rep('*tot',1000),c2=df$c2 ,c3=rep('*tot',1000)),mean)</div><div class="gmail_default">tc3 <- aggregate(list(medvar = df$var), list(c1=rep('*tot',1000),c2=rep('*tot',1000),c3=df$c3 ),mean)</div>
<div class="gmail_default">tc1c2 <- aggregate(list(medvar = df$var), list(c1=df$c1 ,c2=df$c2 ,c3=rep('*tot',1000)),mean)</div><div class="gmail_default">tc1c3 <- aggregate(list(medvar = df$var), list(c1=df$c1 ,c2=rep('*tot',1000),c3=df$c3 ),mean)</div>
<div class="gmail_default">tc2c3 <- aggregate(list(medvar = df$var), list(c1=rep('*tot',1000),c2=df$c2 ,c3=df$c3 ),mean)</div><div class="gmail_default">tc1c2c3 <- aggregate(list(medvar = df$var), list(c1=df$c1 ,c2=df$c2 ,c3=df$c3),mean)</div>
<div class="gmail_default">comp2 <- rbind(t1,tc1,tc2,tc3,tc1c2,tc1c3,tc2c3,tc1c2c3)</div><div class="gmail_default">rm(tc1,tc2,tc3,tc1c2,tc1c3,tc2c3,tc1c2c3)</div><div class="gmail_default"><br></div><div class="gmail_default">
comp <- merge(comp1,comp2,by=c('c1','c2','c3'),all=T)</div><div class="gmail_default">rm(comp1,comp2)</div><div><br></div></font></div><div class="gmail_default"><font color="#333333" face="trebuchet ms, sans-serif"><br>
</font></div><div class="gmail_default"><font color="#333333" face="trebuchet ms, sans-serif">Exite algum pacote que faca isso?</font></div><div class="gmail_default"><font color="#333333" face="trebuchet ms, sans-serif"><br>
</font></div><div class="gmail_default"><font color="#333333" face="trebuchet ms, sans-serif"><br></font></div><div class="gmail_default"><font color="#333333" face="trebuchet ms, sans-serif"><br></font></div><div class="gmail_default">
<font color="#333333" face="trebuchet ms, sans-serif"><br></font></div><div><font color="#333333" face="trebuchet ms, sans-serif"><br></font></div></div></div></div>
<br>_______________________________________________<br>
R-br mailing list<br>
<a href="mailto:R-br@listas.c3sl.ufpr.br">R-br@listas.c3sl.ufpr.br</a><br>
<a href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br" target="_blank">https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br</a><br>
Leia o guia de postagem (<a href="http://www.leg.ufpr.br/r-br-guia" target="_blank">http://www.leg.ufpr.br/r-br-guia</a>) e forneça código mínimo reproduzível.<br></blockquote></div><br></div>