Dá uma olhada no aggregate<br><br><div id="ymail_android_signature"><a href="https://go.onelink.me/107872968?pid=InProduct&c=Global_Internal_YGrowth_AndroidEmailSig__AndroidUsers&af_wl=ym&af_sub1=Internal&af_sub2=Global_YGrowth&af_sub3=EmailSignature">Enviado do Yahoo Mail no Android</a></div> <br> <blockquote style="margin: 0 0 20px 0;"> <div style="font-family:Roboto, sans-serif; color:#6D00F6;"> <div>Em ter, 6 6e nov 6e 2018 às 15:25, Yury Duarte por (R-br)</div><div><r-br@listas.c3sl.ufpr.br> escreveu:</div> </div> <div style="padding: 10px 0 0 20px; margin: 10px 0 0 0; border-left: 1px solid #6D00F6;"> <div id="yiv1372984759"><div dir="ltr">Boa tarde colegas listeiros, como vão?<div><br></div><div>Tenho um problema e estou com certa dificuldade em resolver de forma prática. Meu conjunto de dados é o seguinte:</div><div><table border="0" cellpadding="0" cellspacing="0" width="352" style="border-collapse:collapse;width:264pt;">
<colgroup><col width="64" style="width:48pt;">
<col width="74" style="width:56pt;">
<col width="75" style="width:56pt;">
<col width="75" style="width:56pt;">
<col width="64" style="width:48pt;">
</colgroup><tbody><tr height="20" style="min-height:15pt;">
<td height="20" width="64" style="min-height:15pt;width:48pt;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">local</td>
<td width="74" style="width:56pt;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">frequencia</td>
<td width="75" style="width:56pt;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">data</td>
<td class="yiv1372984759gmail-xl64" width="75" style="width:56pt;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">quantidade</td>
<td width="64" style="width:48pt;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;"><b>valido</b></td>
</tr>
<tr height="20" style="min-height:15pt;">
<td height="20" style="min-height:15pt;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">A</td>
<td align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">2</td>
<td class="yiv1372984759gmail-xl63" align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">13/05/2015</td>
<td class="yiv1372984759gmail-xl64" align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">500,00</td>
<td align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;"><b>0</b></td>
</tr>
<tr height="20" style="min-height:15pt;">
<td height="20" style="min-height:15pt;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">A</td>
<td align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">2</td>
<td class="yiv1372984759gmail-xl63" align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">13/05/2015</td>
<td class="yiv1372984759gmail-xl64" align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">700,00</td>
<td align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;"><b>1</b></td>
</tr>
<tr height="20" style="min-height:15pt;">
<td height="20" style="min-height:15pt;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">A</td>
<td align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">1</td>
<td class="yiv1372984759gmail-xl63" align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">13/05/2015</td>
<td class="yiv1372984759gmail-xl64" align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">700,00</td>
<td align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;"><b>0</b></td>
</tr>
<tr height="20" style="min-height:15pt;">
<td height="20" style="min-height:15pt;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">B</td>
<td align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">3</td>
<td class="yiv1372984759gmail-xl63" align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">13/05/2015</td>
<td class="yiv1372984759gmail-xl64" align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">400,00</td>
<td align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;"><b>1</b></td>
</tr>
<tr height="20" style="min-height:15pt;">
<td height="20" style="min-height:15pt;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">C</td>
<td align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">5</td>
<td class="yiv1372984759gmail-xl63" align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">13/05/2015</td>
<td class="yiv1372984759gmail-xl64" align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">300,00</td>
<td align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;"><b>0</b></td>
</tr>
<tr height="20" style="min-height:15pt;">
<td height="20" style="min-height:15pt;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">C</td>
<td align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">5</td>
<td class="yiv1372984759gmail-xl63" align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">10/05/2015</td>
<td class="yiv1372984759gmail-xl64" align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">400,00</td>
<td align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;"><b>0</b></td>
</tr>
<tr height="20" style="min-height:15pt;">
<td height="20" style="min-height:15pt;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">C</td>
<td align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">5</td>
<td class="yiv1372984759gmail-xl63" align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">13/05/2016</td>
<td class="yiv1372984759gmail-xl64" align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">400,00</td>
<td align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;"><b>1</b></td>
</tr>
<tr height="20" style="min-height:15pt;">
<td height="20" style="min-height:15pt;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">C</td>
<td align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">5</td>
<td class="yiv1372984759gmail-xl63" align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">13/05/2015</td>
<td class="yiv1372984759gmail-xl64" align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">900,00</td>
<td align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;"><b>1</b></td>
</tr>
<tr height="20" style="min-height:15pt;">
<td height="20" style="min-height:15pt;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">D</td>
<td align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">3</td>
<td class="yiv1372984759gmail-xl63" align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">13/05/2015</td>
<td class="yiv1372984759gmail-xl64" align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">550,00</td>
<td align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;"><b>0</b></td>
</tr>
<tr height="20" style="min-height:15pt;">
<td height="20" style="min-height:15pt;padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">D</td>
<td align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">4</td>
<td class="yiv1372984759gmail-xl63" align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">13/05/2015</td>
<td class="yiv1372984759gmail-xl64" align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;">500,00</td>
<td align="right" style="padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11pt;font-family:Calibri, sans-serif;vertical-align:bottom;border:none;white-space:nowrap;"><b>1</b></td>
</tr>
</tbody></table><br></div><div>Para esse conjunto, gostaria de gerar a coluna 'valida', que me classifica os dados da seguinte maneira: para cada local e para cada ano, retornar apenas o local de maior frequência, mais recente e de maior quantidade (nessa ordem).</div><div>Pensei em gerar um objeto para cada local a partir do which(), mas como meu conjunto de dados tem mais de 150 mil linhas e mais de 2000 locais, achei que essa abordagem não seria muito prática nem rápida de ser processada. </div><div><br></div><div>Desde já, agradeço pela colaboração de todos!</div><div><br></div><div>Att</div><div><br clear="all"><div><div dir="ltr" class="yiv1372984759gmail_signature"><div dir="ltr"><div>Yury Duarte<br></div>Engenheiro Agrônomo - ESALQ/USP<br></div></div></div></div></div></div>_______________________________________________<br>R-br mailing list<br><a ymailto="mailto:R-br@listas.c3sl.ufpr.br" 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. </div> </blockquote>