Tente assim:<div><br></div><div> xtabs(as.numeric(as.character(factor(paste(V3, V4), labels = c(0, 2, 1)))) ~ V2 + V1, base)<br><br><div class="gmail_quote">2012/10/24 <a href="mailto:fabrizzioconde@gmail.com">fabrizzioconde@gmail.com</a> <span dir="ltr"><<a href="mailto:fabrizzioconde@gmail.com" target="_blank">fabrizzioconde@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="MARGIN:5px 10px 0px;FONT-FAMILY:Arial;FONT-SIZE:12pt" bgcolor="#ffffff">
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tbody>
<tr>
<td style="DIRECTION:ltr;FONT-SIZE:12pt" width="100%">
<div style="PADDING-LEFT:2px">
<div>
<div>Caro Augusto,</div>
<div> </div>
<div>Muito obrigado pelas dicas de codificação, resolveram muito bem o problema, mas ainda estou com problema na montagem da tabela final deste e-mail, pois o comando <strong><em>table</em></strong> que sugeriu conta o número de casos de AA, BB e AB na tabela final e o que necessito é posicionar de maneira diferente o dado e não contar o número de vezes que o mesmo aparece nos fatores.</div>
<div> </div>
<div><div><div class="h5">
<div>
<table style="WIDTH:240pt;BORDER-COLLAPSE:collapse" border="0" cellspacing="0" cellpadding="0" width="320">
<colgroup>
<col style="WIDTH:48pt" span="5" width="64">
</colgroup><tbody>
<tr style="min-height:15pt" height="20">
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;WIDTH:48pt;min-height:15pt;BORDER-TOP:windowtext 0.5pt solid;BORDER-RIGHT:windowtext 0.5pt solid" height="20" width="64"><font face="Calibri">AA1</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;WIDTH:48pt;BORDER-TOP:windowtext 0.5pt solid;BORDER-RIGHT:windowtext 0.5pt solid" width="64"><font face="Calibri">1</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;WIDTH:48pt;BORDER-TOP:windowtext 0.5pt solid;BORDER-RIGHT:windowtext 0.5pt solid" width="64"><font face="Calibri">A</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;WIDTH:48pt;BORDER-TOP:windowtext 0.5pt solid;BORDER-RIGHT:windowtext 0.5pt solid" width="64"><font face="Calibri">B</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;WIDTH:48pt;BORDER-TOP:windowtext 0.5pt solid;BORDER-RIGHT:windowtext 0.5pt solid" width="64"><font face="Calibri">2</font></td></tr>
<tr style="min-height:15pt" height="20">
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;min-height:15pt;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid" height="20"><font face="Calibri">AA2</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">1</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">A</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">A</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">0</font></td></tr>
<tr style="min-height:15pt" height="20">
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;min-height:15pt;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid" height="20"><font face="Calibri">AA3</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">1</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">B</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">B</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">1</font></td></tr>
<tr style="min-height:15pt" height="20">
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;min-height:15pt;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid" height="20"><font face="Calibri">AA4</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">1</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">B</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">B</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">1</font></td></tr>
<tr style="min-height:15pt" height="20">
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;min-height:15pt;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid" height="20"><font face="Calibri">AA1</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">2</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">A</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">A</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">0</font></td></tr>
<tr style="min-height:15pt" height="20">
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;min-height:15pt;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid" height="20"><font face="Calibri">AA2</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">2</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">A</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">B</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">2</font></td></tr>
<tr style="min-height:15pt" height="20">
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;min-height:15pt;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid" height="20"><font face="Calibri">AA3</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">2</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">A</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">B</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">2</font></td></tr>
<tr style="min-height:15pt" height="20">
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;min-height:15pt;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid" height="20"><font face="Calibri">AA4</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">2</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">A</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">A</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">0</font></td></tr>
<tr style="min-height:15pt" height="20">
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;min-height:15pt;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid" height="20"><font face="Calibri">AA1</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">3</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">B</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">B</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">1</font></td></tr>
<tr style="min-height:15pt" height="20">
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;min-height:15pt;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid" height="20"><font face="Calibri">AA2</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">3</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">B</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">B</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">1</font></td></tr>
<tr style="min-height:15pt" height="20">
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;min-height:15pt;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid" height="20"><font face="Calibri">AA3</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">3</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">A</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">A</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">0</font></td></tr>
<tr style="min-height:15pt" height="20">
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;min-height:15pt;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid" height="20"><font face="Calibri">AA4</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">3</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">A</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">A</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">0</font></td></tr>
<tr style="min-height:15pt" height="20">
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;min-height:15pt;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid" height="20"><font face="Calibri">AA1</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">4</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">B</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">B</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">1</font></td></tr>
<tr style="min-height:15pt" height="20">
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;min-height:15pt;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid" height="20"><font face="Calibri">AA2</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">4</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">A</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">B</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">2</font></td></tr>
<tr style="min-height:15pt" height="20">
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;min-height:15pt;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid" height="20"><font face="Calibri">AA3</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">4</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">A</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">A</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">1</font></td></tr>
<tr style="min-height:15pt" height="20">
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;min-height:15pt;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid" height="20"><font face="Calibri">AA4</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">4</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">A</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">B</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">2</font></td></tr></tbody></table></div>
<div> </div>
</div></div><div>Desta forma, note que o elemento (1,5) na tabela acima foi colocado na posição (1,1) da tabela abaixo. O elemento (5,5) foi colocado na posição (2,1). O elemento (9,5) foi inserido na posição (3,1) e o elemento (13,5) está na posição (4,1). Assim, consigo capturar a variável AA1 de cada indivíduo (1, 2, 3 e 4). Da mesma forma, o elemento (2,5) foi colocado na posição (1,2), o elemento (6,5) foi inserido na posição (2,2) e assim sucessivamente.</div>
<div class="im">
<div> </div>
<div>
<table style="WIDTH:240pt;BORDER-COLLAPSE:collapse" border="0" cellspacing="0" cellpadding="0" width="320">
<colgroup>
<col style="WIDTH:48pt" span="5" width="64">
</colgroup><tbody>
<tr style="min-height:15pt" height="20">
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;WIDTH:48pt;min-height:15pt;BORDER-TOP:windowtext 0.5pt solid;BORDER-RIGHT:windowtext 0.5pt solid" height="20" width="64"><font face="Calibri"> </font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;WIDTH:48pt;BORDER-TOP:windowtext 0.5pt solid;BORDER-RIGHT:windowtext 0.5pt solid" width="64"><font face="Calibri">AA1</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;WIDTH:48pt;BORDER-TOP:windowtext 0.5pt solid;BORDER-RIGHT:windowtext 0.5pt solid" width="64"><font face="Calibri">AA2</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;WIDTH:48pt;BORDER-TOP:windowtext 0.5pt solid;BORDER-RIGHT:windowtext 0.5pt solid" width="64"><font face="Calibri">AA3</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;WIDTH:48pt;BORDER-TOP:windowtext 0.5pt solid;BORDER-RIGHT:windowtext 0.5pt solid" width="64"><font face="Calibri">AA4</font></td></tr>
<tr style="min-height:15pt" height="20">
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;min-height:15pt;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid" height="20"><font face="Calibri">1</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">2</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">0</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">1</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">1</font></td></tr>
<tr style="min-height:15pt" height="20">
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;min-height:15pt;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid" height="20"><font face="Calibri">2</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">0</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">2</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">2</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">0</font></td></tr>
<tr style="min-height:15pt" height="20">
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;min-height:15pt;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid" height="20"><font face="Calibri">3</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">1</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">1</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">0</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">0</font></td></tr>
<tr style="min-height:15pt" height="20">
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;min-height:15pt;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid" height="20"><font face="Calibri">4</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">1</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">2</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">1</font></td>
<td style="BORDER-BOTTOM:windowtext 0.5pt solid;BACKGROUND-COLOR:transparent;BORDER-TOP:windowtext;BORDER-RIGHT:windowtext 0.5pt solid"><font face="Calibri">2</font></td></tr></tbody></table></div></div></div>
<div> </div>
<div>Não consigo fazer esse redimensionamento da tabela antiga para a nova.</div>
<div> </div>
<div>Desde já agradeço imensamente sua ajuda.</div>
<div> </div>
<div>Abraços,</div>
<div>Fabrízzio</div>
<div> </div>
<div> </div>
<div> </div></div></div>
<div>
<div> </div>
<div> </div>
<div style="FONT-SIZE:11pt" dir="ltr"><i>-------Original Message-------</i></div>
<div> </div>
<div>
<div style="FONT-SIZE:11pt" dir="ltr"><i><b>From:</b></i> <a href="mailto:r-br-request@listas.c3sl.ufpr.br" target="_blank">r-br-request@listas.c3sl.ufpr.br</a></div>
<div style="FONT-SIZE:11pt" dir="ltr"><i><b>Date:</b></i> 24/10/2012 12:00:14</div>
<div style="FONT-SIZE:11pt" dir="ltr"><i><b>To:</b></i> <a href="mailto:r-br@listas.c3sl.ufpr.br" target="_blank">r-br@listas.c3sl.ufpr.br</a></div>
<div style="FONT-SIZE:11pt" dir="ltr"><i><b>Subject:</b></i> Digest R-br, volume 20, assunto 30</div></div>
<div> </div>
<div>Enviar submissões para a lista de discussão R-br para</div>
<div> <a href="mailto:r-br@listas.c3sl.ufpr.br" target="_blank">r-br@listas.c3sl.ufpr.br</a></div>
<div> </div>
<div>Para se cadastrar ou descadastrar via WWW, visite o endereço</div>
<div> <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></div>
<div>ou, via email, envie uma mensagem com a palavra 'help' no assunto ou</div>
<div>corpo da mensagem para</div>
<div> <a href="mailto:r-br-request@listas.c3sl.ufpr.br" target="_blank">r-br-request@listas.c3sl.ufpr.br</a></div>
<div> </div>
<div>Você poderá entrar em contato com a pessoa que gerencia a lista pelo</div>
<div>endereço</div>
<div> <a href="mailto:r-br-owner@listas.c3sl.ufpr.br" target="_blank">r-br-owner@listas.c3sl.ufpr.br</a></div>
<div> </div>
<div>Quando responder, por favor edite sua linha Assunto assim ela será</div>
<div>mais específica que "Re: Contents of R-br digest..."</div>
<div> </div>
<div> </div>
<div>Tópicos de Hoje:</div>
<div> </div>
<div> 1. Re: Transformação de dados no dataframe (Augusto Ribas)</div>
<div> </div>
<div> </div>
<div>----------------------------------------------------------------------</div>
<div> </div>
<div>Message: 1</div>
<div>Date: Wed, 24 Oct 2012 09:50:12 -0300</div>
<div>From: Augusto Ribas <<a href="mailto:ribas.aca@gmail.com" target="_blank">ribas.aca@gmail.com</a>></div>
<div>To: <a href="mailto:r-br@listas.c3sl.ufpr.br" target="_blank">r-br@listas.c3sl.ufpr.br</a></div>
<div>Subject: Re: [R-br] Transformação de dados no dataframe</div>
<div>Message-ID:</div>
<div> <<a href="mailto:CACMkfRyM6o+=mvtJ7GuQXn2xMiNYgGdo1Za0m0erZ6aw6Xc09g@mail.gmail.com" target="_blank">CACMkfRyM6o+=mvtJ7GuQXn2xMiNYgGdo1Za0m0erZ6aw6Xc09g@mail.gmail.com</a>></div>
<div>Content-Type: text/plain; charset="windows-1252"</div><div><div class="h5">
<div> </div>
<div>Vamos supor um exemplo de dados:</div>
<div> </div>
<div>#dados de exemplo</div>
<div>dados<-data.frame(col1=round(runif(20,1,4)),col2=sample(c("A","B"),20,replace=T),col3=sample(c("A","B"),20,replace=T))</div>
<div>dados</div>
<div> </div>
<div> </div>
<div>#primeiro com o comando paste, vamos juntar a coluna 2 com a 3, criando os</div>
<div>AA AB e BB</div>
<div>dados$col4<-factor(paste(dados$col2,dados$col3,sep=""))</div>
<div> </div>
<div>#Depois como os walmes nos ensinou aqui na lista, a gente usa o match()</div>
<div>#para recodificar nos valores que queremos, no caso como vc falou</div>
<div> </div>
<div>levels(dados$col4)</div>
<div>recod<-c(0,1,1,2)</div>
<div>dados$col5<-recod[match(dados$col4,levels(dados$col4))]</div>
<div>dados</div>
<div> </div>
<div> </div>
<div>#agora que vc te todos os ingredientes, é so usar o comando table() para</div>
<div>fazer essa tabela</div>
<div>#eu fiz um exemplo de tabela com a coluna 5 e a coluna 5, mas pelo que vi</div>
<div>vc quer a coluna</div>
<div>#5 e os nomes das linhas, rownames(sua planilha), entao use os nomes da</div>
<div>linha na tabela</div>
<div>table(dados$col5,dados$col4)</div>
<div> </div>
<div>Espero que ajude.</div>
<div>Abraços</div>
<div> </div>
<div>Em 24 de outubro de 2012 09:16, <a href="mailto:fabrizzioconde@gmail.com" target="_blank">fabrizzioconde@gmail.com</a> <</div>
<div><a href="mailto:fabrizzioconde@gmail.com" target="_blank">fabrizzioconde@gmail.com</a>> escreveu:</div>
<div> </div>
<div>> Bom dia,</div>
<div>></div>
<div>> Existe algum script que faça o seguinte:</div>
<div>></div>
<div>> 1) Cria uma quinta coluna na matriz abaixo baseada na terceira e na quarta</div>
<div>> coluna DA seguinte forma: AA = 0, BB = 1 e AB = 2.</div>
<div>></div>
<div>> AA1 1 A B AA2 1 A A AA3 1 B B AA4 1 B B AA1 2 A A AA2 2 A B AA3 2 A B</div>
<div>> AA4 2 A A AA1 3 B B AA2 3 B B AA3 3 A A AA4 3 A A AA1 4 B B AA2 4 A B AA3</div>
<div>> 4 A A AA4 4 A B</div>
<div>></div>
<div>> Assim, a matriz se transformaria em:</div>
<div>></div>
<div>> AA1 1 A B 2 AA2 1 A A 0 AA3 1 B B 1 AA4 1 B B 1 AA1 2 A A 0 AA2 2 A B 2</div>
<div>> AA3 2 A B 2 AA4 2 A A 0 AA1 3 B B 1 AA2 3 B B 1 AA3 3 A A 0 AA4 3 A A 0</div>
<div>> AA1 4 B B 1 AA2 4 A B 2 AA3 4 A A 1 AA4 4 A B 2</div>
<div>></div>
<div>> 2) Após esse passo, tenho que eliminar as colunas 3 e 4 DA matriz acima</div>
<div>> (talvez em um novo dataframe) e redimensioná-la para o seguinte formato:</div>
<div>></div>
<div>> AA1 AA2 AA3 AA4 1 2 0 1 1 2 0 2 2 0 3 1 1 0 0 4 1 2 1 2</div>
<div>></div>
<div>> Ao final, preciso que cada coluna DA matriz acima seja encarada pelo R</div>
<div>> como uma variável (AA1, AA2, AA3, AA4), pois irei aplicar o pacote de</div>
<div>> regressão logística penalizada stepPlr e considerar essas variáveis</div>
<div>> preditoras.</div>
<div>></div>
<div>> Muito obrigado.</div>
<div>> Fabrízzio</div>
</div></div><div>> [image: FREE Christmas Animations for your email ? by IncrediMail!</div>
<div>> Click Here!]<<a href="http://www.incredimail.com/?id=620188&did=10500&ppd=2747,201111071523,9" target="_blank">http://www.incredimail.com/?id=620188&did=10500&ppd=2747,201111071523,9</a>,[TypeID],[IM_UPN2]&rui=139771782&sd=20121024></div>
<div class="im">
<div>></div>
<div>> _______________________________________________</div>
<div>> R-br mailing list</div>
<div>> <a href="mailto:R-br@listas.c3sl.ufpr.br" target="_blank">R-br@listas.c3sl.ufpr.br</a></div>
<div>> <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></div>
<div>> 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</div>
<div>> código mínimo reproduzível.</div>
<div>></div>
<div> </div>
<div> </div>
<div> </div>
<div>--</div>
<div>Grato</div>
<div>Augusto C. A. Ribas</div>
<div> </div>
<div>Site Pessoal: <a href="http://augustoribas.heliohost.org" target="_blank">http://augustoribas.heliohost.org</a></div>
<div>Lattes: <a href="http://lattes.cnpq.br/7355685961127056" target="_blank">http://lattes.cnpq.br/7355685961127056</a></div>
</div><div>-------------- Próxima Parte ----------</div>
<div>Um anexo em HTML foi limpo...</div>
<div>URL: <<a href="http://listas.inf.ufpr.br/pipermail/r-br/attachments/20121024/96f8c562/attachment-0001.html" target="_blank">http://listas.inf.ufpr.br/pipermail/r-br/attachments/20121024/96f8c562/attachment-0001.html</a>></div>
<div>-------------- Próxima Parte ----------</div>
<div>Um anexo não-texto foi limpo...</div>
<div>Nome: xmas_girl_en.gif</div>
<div>Tipo: image/gif</div>
<div>Tamanho: 61041 bytes</div>
<div>Descrição: não disponível</div>
<div>URL: <<a href="http://listas.inf.ufpr.br/pipermail/r-br/attachments/20121024/96f8c562/attachment-0001.gif" target="_blank">http://listas.inf.ufpr.br/pipermail/r-br/attachments/20121024/96f8c562/attachment-0001.gif</a>></div>
<div> </div>
<div>------------------------------</div><div class="im">
<div> </div>
<div>_______________________________________________</div>
<div>R-br mailing list</div>
<div><a href="mailto:R-br@listas.c3sl.ufpr.br" target="_blank">R-br@listas.c3sl.ufpr.br</a></div>
<div><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></div>
<div> </div>
<div> </div>
</div><div>Fim da Digest R-br, volume 20, assunto 30</div>
<div>*****************************************</div></div></td></tr>
<tr>
<td width="100%">
<table cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td width="100%"></td>
<td valign="bottom" align="middle"></td></tr></tbody></table></td></tr></tbody></table><div class="im"><span><a href="http://www.incredimail.com/?id=620188&did=10500&ppd=2747,201111071523,9,[TypeID],[IM_UPN2]&rui=139771782&sd=20121024" target="_blank"><span name="imgCache" border="0"><img border="0" alt="FREE Christmas Animations for your email – by IncrediMail! Click Here!" src="cid:FDFF2C04-C399-40D8-AD49-28DC69246FE0"></span></a></span></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><br clear="all"><div><br></div>-- <br>
Henrique Dallazuanna<br>Curitiba-Paraná-Brasil<br>25° 25' 40" S 49° 16' 22" O<br>
</div>