<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:Verdana;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:"Trebuchet MS";
panose-1:2 11 6 3 2 2 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EstiloDeEmail17
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;}
@page Section1
{size:612.0pt 792.0pt;
margin:70.85pt 3.0cm 70.85pt 3.0cm;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=PT-BR link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><span style='font-family:"Arial","sans-serif";color:black'>Não
consegui rodar, alguém sabe o motivo?<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-family:"Arial","sans-serif";color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-family:"Arial","sans-serif";
color:#1F497D'>> require(RCurl)); require(XML)<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-family:"Arial","sans-serif";
color:#1F497D'>Loading required package: RCurl<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-family:"Arial","sans-serif";
color:#1F497D'>Loading required package: bitops<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-family:"Arial","sans-serif";
color:#1F497D'>Loading required package: XML<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-family:"Arial","sans-serif";
color:#1F497D'>> url0 <-
"https://www.dropbox.com/s/znmr0lwda2y6fc5/BD_teste2.html?dl=1"<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-family:"Arial","sans-serif";
color:#1F497D'>> url1 <- gsub("(^.*)(/s/.*)(\\?.*$)",
"https://dl.dropboxusercontent.com\\2", url0); url1<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-family:"Arial","sans-serif";
color:#1F497D'>[1]
"https://dl.dropboxusercontent.com/s/znmr0lwda2y6fc5/BD_teste2.html"<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-family:"Arial","sans-serif";
color:#1F497D'>> # [1]
"https://dl.dropboxusercontent.com/s/znmr0lwda2y6fc5/BD_teste2.html"<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-family:"Arial","sans-serif";
color:#1F497D'>> <o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-family:"Arial","sans-serif";
color:#1F497D'>> page <- getURL(url1)<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-family:"Arial","sans-serif";
color:#1F497D'>Error in function (type, msg, asError = TRUE) : <o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-family:"Arial","sans-serif";
color:#1F497D'> SSL certificate problem, verify that the CA cert is OK. </span><span
style='font-family:"Arial","sans-serif";color:#1F497D'>Details:<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-family:"Arial","sans-serif";
color:#1F497D'>error:14090086:SSL
routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'>
<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>De:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> R-br
[mailto:r-br-bounces@listas.c3sl.ufpr.br] <b>Em nome de </b>Éder Comunello<br>
<b>Enviada em:</b> sexta-feira, 29 de janeiro de 2016 09:41<br>
<b>Para:</b> ASANTOS<br>
<b>Cc:</b> r-br@listas.c3sl.ufpr.br<br>
<b>Assunto:</b> Re: [R-br] RES: Criar função para tirar a média entre grupos
sob condições dadas<o:p></o:p></span></p>
</div>
<p class=MsoNormal><o:p> </o:p></p>
<div>
<div>
<div>
<p class=MsoNormal><span style='font-family:"Verdana","sans-serif"'>Alexandre,
bom dia!</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Verdana","sans-serif"'>Não havia
atentado para o problema na importação das tabelas, sendo necessário
definir as classes. Além disso, na função você deve se referir a "db"
antes que "tableFE" e "x" é definido internamente por
lapply().</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>### <code r></span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>require(RCurl);
require(XML)</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>url0 <- "<a
href="https://www.dropbox.com/s/znmr0lwda2y6fc5/BD_teste2.html?dl=1">https://www.dropbox.com/s/znmr0lwda2y6fc5/BD_teste2.html?dl=1</a>"</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>url1 <-
gsub("(^.*)(/s/.*)(\\?.*$)", "<a
href="https://dl.dropboxusercontent.com">https://dl.dropboxusercontent.com</a>\\2",
url0); url1</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'># [1] "<a
href="https://dl.dropboxusercontent.com/s/znmr0lwda2y6fc5/BD_teste2.html">https://dl.dropboxusercontent.com/s/znmr0lwda2y6fc5/BD_teste2.html</a>"</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>page <-
getURL(url1)</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>tableFE <-
readHTMLTable(page, head=T)[[1]]</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>str(tableFE) ###
todas variáveis estão como fatores - corrigir!</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>classes <-
c(rep("factor", 6), rep("numeric", 4), "factor")</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>tableFE <-
readHTMLTable(page, head=T, colClasses=classes)[[1]]</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>str(tableFE) ### OK!</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>head(tableFE)</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>##Agregando os
resultados</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>aggPestFE <-
function(db=tableFE, key="descricao"){</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>lista <-
split(db, db[key])</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>result <-
lapply(lista, function(x) aggregate(x[,7:8], by=list(x[,3],x[,2],x[,5]), mean))</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>return(result)</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>}</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>### Devido aos
"defaults", obtém mesmos resultados nas três formas que seguem:</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>aggPestFE()[5]</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>aggPestFE(tableFE)[5]</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>aggPestFE(tableFE,
"descricao")[5]</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'># $`Lagartas
Desfolhadoras`</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'># Group.1
Group.2 Group.3 formiga_area qtd_destruido</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'># 1
GN Chale 26
0
62.5</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'># 2
RD Corrego da Coruja 26
0 50.0</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'># 3
GN Aeroporto II 28
0 75.0</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>### </code></span><o:p></o:p></p>
</div>
</div>
<div>
<p class=MsoNormal><br clear=all>
<o:p></o:p></p>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class=MsoNormal><span style='font-family:"Cambria Math","serif"'></span><span
style='font-family:"Trebuchet MS","sans-serif"'><o:p></o:p></span></p>
</div>
<p class=MsoNormal><span style='font-family:"Arial","sans-serif"'>================================================<br>
Éder Comunello</span><o:p></o:p></p>
<div>
<p class=MsoNormal><span style='font-family:"Arial","sans-serif"'>PhD Student
in Agricultural Systems Engineering (USP/Esalq)</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal>Brazilian Agricultural Research Corporation (<span
style='font-family:"Arial","sans-serif"'>Embrapa)</span><o:p></o:p></p>
<div>
<p class=MsoNormal><span style='font-family:"Arial","sans-serif"'>Dourados, MS,
Brazil [</span>22 16.5'S, 54 49.0'W<span style='font-family:"Arial","sans-serif"'>]</span><o:p></o:p></p>
</div>
<div>
<div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
</div>
<div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br /><br />
<hr style='border:none; color:#909090; background-color:#B0B0B0; height: 1px; width: 99%;' />
<table style='border-collapse:collapse;border:none;'>
<tr>
<td style='border:none;padding:0px 15px 0px 8px'>
<a href="https://www.avast.com/antivirus">
<img border=0 src="http://static.avast.com/emails/avast-mail-stamp.png" alt="Avast logo" />
</a>
</td>
<td>
<p style='color:#3d4d5a; font-family:"Calibri","Verdana","Arial","Helvetica"; font-size:12pt;'>
Este email foi escaneado pelo Avast antivírus.
<br><a href="https://www.avast.com/antivirus">www.avast.com</a>
</p>
</td>
</tr>
</table>
<br />
</body>
</html>