<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif">Senhores, bom dia!</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">Uma outra alternativa para baixar direto do dropbox...</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style=""><div class="gmail_default"><font face="monospace, monospace">### <code r></font></div><div class="gmail_default"><font face="monospace, monospace">require(RCurl); require(XML)</font></div><div class="gmail_default"><font face="monospace, monospace">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>"</font></div><div class="gmail_default"><font face="monospace, monospace">url1 <- "<a href="https://dl.dropboxusercontent.com/s/znmr0lwda2y6fc5/BD_teste2.html">https://dl.dropboxusercontent.com/s/znmr0lwda2y6fc5/BD_teste2.html</a>"</font></div><div class="gmail_default"><font face="monospace, monospace"><br></font></div><div class="gmail_default"><font face="monospace, monospace">page <- getURL(url1)</font></div><div class="gmail_default"><font face="monospace, monospace">tableFE <- readHTMLTable(page, head=T)[[1]]</font></div><div class="gmail_default"><font face="monospace, monospace">head(tableFE)</font></div><div class="gmail_default"><font face="monospace, monospace"><br></font></div><div class="gmail_default"><font face="monospace, monospace">##Agregando os resultados</font></div><div class="gmail_default"><font face="monospace, monospace">lista <- split(tableFE, tableFE$descricao); head(lista)</font></div><div class="gmail_default"><font face="monospace, monospace">lapply(lista, function(x) aggregate(x[,7:8], by=list(x[,2], x[,5]), mean))  </font></div><div class="gmail_default"><font face="monospace, monospace">### </code></font></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><font face="arial, helvetica, sans-serif" style="font-size:small"><div style="font-family:'trebuchet ms',sans-serif;display:inline">​</div>================================================<br>Éder Comunello</font><div style="font-size:small"><span style="font-family:arial,helvetica,sans-serif">PhD Student in Agricultural Systems Engineering (USP/Esalq)</span><br></div><div><span style="font-size:small">Brazilian Agricultural Research Corporation (</span><font face="arial, helvetica, sans-serif" style="font-size:small">Embrapa)</font><div style="font-size:small"><font face="arial, helvetica, sans-serif">Dourados, MS, Brazil [</font>22 16.5'S, 54 49.0'W<span style="font-family:arial,helvetica,sans-serif">]</span></div><div><div><br></div><div><br></div></div><div style="font-size:small"><br></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">Em 22 de janeiro de 2016 08:16, ASANTOS <span dir="ltr"><<a href="mailto:alexandresantosbr@yahoo.com.br" target="_blank">alexandresantosbr@yahoo.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 bgcolor="#FFFFFF" text="#000000">
    Segue o solicitado Mauro,<br>
    <br>
    <br>
    ##Pacotes
    e-------------------------------------------------------------<br>
    require(httr)<br>
    require(XML)<br>
    <br>
    <br>
    ##  Função de leitura do banco de dados do APP
    #--------------------------------<span class=""><br>
    readFE<- function (x, URL = ""){<br>
    FILE <- GET(url=URL)<br>
         tables <- getNodeSet(htmlParse(FILE), "//table") <br>
         FE_tab <- readHTMLTable(tables[[1]], <br>
                            header =
    c("empresa","desc_projeto","desc_regiao", <br>
                                      
    "cadastrador_por","cod_talhao","descricao", <br>
                                      
    "formiga_area","qtd_destruido","latitude", <br>
                                       "longitude","data_cadastro"), <br>
                            colClasses =
    c("character","character","character", <br>
                                          
    "character","numeric","character", <br>
                                          
    "numeric","numeric","numeric", <br>
                                           "numeric","character"), <br>
                            trim = TRUE, stringsAsFactors = FALSE <br>
    )     <br>
         x<-NULL<br>
         results <- x<br>
         x<-FE_tab[-(1),]<br>
         results <- x<br>
        
    results<-results[!apply(results,1,function(x){any(x=="(NULL)")}),]<br>
         results<br>
    }<br>
    #--#<br>
tableFE<-readFE(URL=<a href="https://www.dropbox.com/s/znmr0lwda2y6fc5/BD_teste2.html?dl=1" target="_blank">"https://www.dropbox.com/s/znmr0lwda2y6fc5/BD_teste2.html?dl=1"</a>)<br></span>
    head(tableFE)<br>
    #------<br>
    <br>
    lista <- split(tableFE, tableFE$descricao)<br>
    lapply(lista, function(x) aggregate(x[,7:8],
    by=list(x[,3],x[,2],x[,5]), mean))<span class=""><br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <pre cols="72">-- 
======================================================================
Alexandre dos Santos
Proteção Florestal 
IFMT - Instituto Federal de Educação, Ciência e Tecnologia de Mato Grosso
Campus Cáceres
Caixa Postal 244
Avenida dos Ramires, s/n
Bairro: Distrito Industrial 
Cáceres - MT                      CEP: 78.200-000
Fone: <a href="tel:%28%2B55%29%2065%208132-8112" value="+556581328112" target="_blank">(+55) 65 8132-8112</a> (TIM)   <a href="tel:%28%2B55%29%2065%209686-6970" value="+556596866970" target="_blank">(+55) 65 9686-6970</a> (VIVO)
<a href="mailto:e-mails:alexandresantosbr@yahoo.com.br" target="_blank">e-mails:alexandresantosbr@yahoo.com.br</a> 
        <a href="mailto:alexandre.santos@cas.ifmt.edu.br" target="_blank">alexandre.santos@cas.ifmt.edu.br</a> 
Lattes: <a href="http://lattes.cnpq.br/1360403201088680" target="_blank">http://lattes.cnpq.br/1360403201088680</a>
OrcID: <a href="http://orcid.org/0000-0001-8232-6722" target="_blank">orcid.org/0000-0001-8232-6722</a> 
Researchgate: <a href="https://www.researchgate.net/profile/Alexandre_Santos10" target="_blank">https://www.researchgate.net/profile/Alexandre_Santos10</a>                       
LinkedIn: <a href="https://br.linkedin.com/in/alexandre-dos-santos-87961635" target="_blank">https://br.linkedin.com/in/alexandre-dos-santos-87961635</a>
======================================================================
</pre>
    </span><div><div class="h5"><div>Em 22/01/2016 03:20, Mauro Sznelwar
      escreveu:<br>
    </div>
    </div></div><blockquote type="cite"><div><div class="h5">
      
      
      
      <div>
        <p class="MsoNormal"><span style="font-family:"Arial","sans-serif";color:#1f497d">Pode
passar
            o código com o data-set para rodar?</span><span style="font-family:"Arial","sans-serif""><u></u><u></u></span></p>
        <p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
        <p class="MsoNormal">Muito obrigado Éder e Manuel, faltou o
          pacote httr,<br>
          <br>
          Abraços,<br>
          <br>
          <u></u><u></u></p>
        <pre>-- <u></u><u></u></pre>
        <pre>======================================================================<u></u><u></u></pre>
        <pre>Alexandre dos Santos<u></u><u></u></pre>
        <pre>Proteção Florestal <u></u><u></u></pre>
        <pre>IFMT - Instituto Federal de Educação, Ciência e Tecnologia de Mato Grosso<u></u><u></u></pre>
        <pre>Campus Cáceres<u></u><u></u></pre>
        <pre>Caixa Postal 244<u></u><u></u></pre>
        <pre>Avenida dos Ramires, s/n<u></u><u></u></pre>
        <pre>Bairro: Distrito Industrial <u></u><u></u></pre>
        <pre>Cáceres - MT                      CEP: 78.200-000<u></u><u></u></pre>
        <pre>Fone: <a href="tel:%28%2B55%29%2065%208132-8112" value="+556581328112" target="_blank">(+55) 65 8132-8112</a> (TIM)   <a href="tel:%28%2B55%29%2065%209686-6970" value="+556596866970" target="_blank">(+55) 65 9686-6970</a> (VIVO)<u></u><u></u></pre>
        <pre><a href="mailto:e-mails:alexandresantosbr@yahoo.com.br" target="_blank">e-mails:alexandresantosbr@yahoo.com.br</a> <u></u><u></u></pre>
        <pre>        <a href="mailto:alexandre.santos@cas.ifmt.edu.br" target="_blank">alexandre.santos@cas.ifmt.edu.br</a> <u></u><u></u></pre>
        <pre>Lattes: <a href="http://lattes.cnpq.br/1360403201088680" target="_blank">http://lattes.cnpq.br/1360403201088680</a><u></u><u></u></pre>
        <pre>OrcID: <a href="http://orcid.org/0000-0001-8232-6722" target="_blank">orcid.org/0000-0001-8232-6722</a> <u></u><u></u></pre>
        <pre>Researchgate: <a href="https://www.researchgate.net/profile/Alexandre_Santos10" target="_blank">https://www.researchgate.net/profile/Alexandre_Santos10</a>                       <u></u><u></u></pre>
        <pre>LinkedIn: <a href="https://br.linkedin.com/in/alexandre-dos-santos-87961635" target="_blank">https://br.linkedin.com/in/alexandre-dos-santos-87961635</a><u></u><u></u></pre>
        <pre>======================================================================<u></u><u></u></pre>
        <div>
          <p class="MsoNormal">Em 21/01/2016 21:48, Éder Comunello
            escreveu:<u></u><u></u></p>
        </div>
        <blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
          <div>
            <div>
              <p class="MsoNormal"><span style="font-family:"Verdana","sans-serif"">Alexandre,</span><u></u><u></u></p>
            </div>
            <div>
              <p class="MsoNormal"><u></u> <u></u></p>
            </div>
            <div>
              <p class="MsoNormal"><span style="font-family:"Verdana","sans-serif"">Tente
                  a
                  seguinte linha:</span><u></u><u></u></p>
            </div>
            <div>
              <p class="MsoNormal"><u></u> <u></u></p>
            </div>
            <div>
              <p class="MsoNormal"><span style="font-family:"Verdana","sans-serif"">l</span><span style="font-family:"Courier New"">apply(lista,
                  function(x) aggregate(x[,7:8],
                  by=list(x[,2], x[,5]), mean)) </span><span style="font-family:"Verdana","sans-serif""> </span><u></u><u></u></p>
            </div>
          </div>
          <div>
            <p class="MsoNormal"><br clear="all">
              <u></u><u></u></p>
            <div>
              <div>
                <div>
                  <div>
                    <div>
                      <div>
                        <div>
                          <div>
                            <p class="MsoNormal"><span>​</span><span><u></u><u></u></span></p>
                          </div>
                          <p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">================================================<br>
                              Éder Comunello</span> <u></u><u></u></p>
                          <div>
                            <p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">PhD
                                Student
                                in Agricultural Systems
                                Engineering (USP/Esalq)</span><u></u><u></u></p>
                          </div>
                          <div>
                            <p class="MsoNormal">Brazilian Agricultural
                              Research Corporation (<span style="font-family:"Arial","sans-serif"">Embrapa)</span>
                              <u></u><u></u></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><u></u><u></u></p>
                            </div>
                            <div>
                              <div>
                                <p class="MsoNormal"><u></u> <u></u></p>
                              </div>
                              <div>
                                <p class="MsoNormal"><u></u> <u></u></p>
                              </div>
                            </div>
                            <div>
                              <p class="MsoNormal"><u></u> <u></u></p>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <p class="MsoNormal"><u></u> <u></u></p>
            <div>
              <p class="MsoNormal">Em 21 de janeiro de 2016 17:55,
                Manoel Galdino <<a href="mailto:mcz.fea@gmail.com" target="_blank">mcz.fea@gmail.com</a>>
                escreveu:<u></u><u></u></p>
              <div>
                <div>
                  <p class="MsoNormal" style="margin-bottom:12.0pt">Nem
                    consigo executar sua função
                    de begar o banco, diz q não existe GET<u></u><u></u></p>
                </div>
                <p class="MsoNormal">cheguei a carrega o pacote XML, mas
                  tbm não funfou<u></u><u></u></p>
              </div>
              <div>
                <div>
                  <div>
                    <p class="MsoNormal"><u></u> <u></u></p>
                    <div>
                      <p class="MsoNormal">2016-01-21 18:28 GMT-02:00
                        ASANTOS <<a href="mailto:alexandresantosbr@yahoo.com.br" target="_blank">alexandresantosbr@yahoo.com.br</a>>:<u></u><u></u></p>
                      <div>
                        <p class="MsoNormal">Éder,<br>
                          <br>
                             A sua solução não funcionou com meu exemplo
                          real e não consigo
                          achar o problema, sendo que:<br>
                          <br>
                          ##  Função de leitura do banco de dados <br>
                          readFE<- function (x, URL = ""){<br>
                          FILE <- GET(url=URL)<br>
                               tables <- getNodeSet(htmlParse(FILE),
                          "//table") <br>
                               FE_tab <- readHTMLTable(tables[[1]], <br>
                                                 
                          header =
                          c("empresa","desc_projeto","desc_regiao", <br>
                                                            
                          "cadastrador_por","cod_talhao","descricao", <br>
                                                            
                          "formiga_area","qtd_destruido","latitude", <br>
                                                            
                          "longitude","data_cadastro"), <br>
                                                 
                          colClasses =
                          c("character","character","character", <br>
                                                                
                          "character","numeric","character", <br>
                                                                
                          "numeric","numeric","numeric", <br>
                                                                
                          "numeric","character"), <br>
                                                 
                          trim = TRUE, stringsAsFactors = FALSE <br>
                          )     <br>
                               x<-NULL<br>
                               results <- x<br>
                               x<-FE_tab[-(1),]<br>
                               results <- x<br>
                              
                          results<-results[!apply(results,1,function(x){any(x=="(NULL)")}),]<br>
                               results<br>
                          }<br>
                          #--#<br>
                          tableFE<-readFE(URL=<a href="https://www.dropbox.com/s/znmr0lwda2y6fc5/BD_teste2.html?dl=1" target="_blank"></a><a href="https://www.dropbox.com/s/znmr0lwda2y6fc5/BD_teste2.html?dl=1" target="_blank">"https://www.dropbox.com/s/znmr0lwda2y6fc5/BD_teste2.html?dl=1"</a>)<br>
                          tableFE<-tableFE[1:163,1:11]<br>
                          head(tableFE)<br>
                          <br>
                          ##Agregando os resultados<br>
                          lista <- split(tableFE, tableFE$descricao)<br>
                          lapply(lista, function(x) aggregate(x[,7:8],
                          by=list(x[,2]), mean))  ##
                          Não funciona<br>
                          <br>
                          <br>
                          mas se eu faço item por item funciona e não
                          sei porque, sendo:<br>
                          <br>
                          aggregate(lista$`Psilideo-de-Concha`[,7:8],
                          by=list(lista$`Psilideo-de-Concha`[,2],lista$`Psilideo-de-Concha`[,5]),
                          mean)<br>
                          <br>
                          Poderia me dar mais um help?<br>
                          <br>
                          Obrigado,<br>
                          <br>
                          Abraços<br>
                          <br>
                          <u></u><u></u></p>
                        <pre>-- <u></u><u></u></pre>
                        <pre>======================================================================<u></u><u></u></pre>
                        <pre>Alexandre dos Santos<u></u><u></u></pre>
                        <pre>Proteção Florestal <u></u><u></u></pre>
                        <pre>IFMT - Instituto Federal de Educação, Ciência e Tecnologia de Mato Grosso<u></u><u></u></pre>
                        <pre>Campus Cáceres<u></u><u></u></pre>
                        <pre>Caixa Postal 244<u></u><u></u></pre>
                        <pre>Avenida dos Ramires, s/n<u></u><u></u></pre>
                        <pre>Bairro: Distrito Industrial <u></u><u></u></pre>
                        <pre>Cáceres - MT                      CEP: 78.200-000<u></u><u></u></pre>
                        <pre>Fone: <a href="tel:%28%2B55%29%2065%208132-8112" target="_blank">(+55) 65 8132-8112</a> (TIM)   <a href="tel:%28%2B55%29%2065%209686-6970" target="_blank">(+55) 65 9686-6970</a> (VIVO)<u></u><u></u></pre>
                        <pre><a href="mailto:e-mails:alexandresantosbr@yahoo.com.br" target="_blank">e-mails:alexandresantosbr@yahoo.com.br</a> <u></u><u></u></pre>
                        <pre>        <a href="mailto:alexandre.santos@cas.ifmt.edu.br" target="_blank">alexandre.santos@cas.ifmt.edu.br</a> <u></u><u></u></pre>
                        <pre>Lattes: <a href="http://lattes.cnpq.br/1360403201088680" target="_blank">http://lattes.cnpq.br/1360403201088680</a><u></u><u></u></pre>
                        <pre>OrcID: <a href="http://orcid.org/0000-0001-8232-6722" target="_blank">orcid.org/0000-0001-8232-6722</a> <u></u><u></u></pre>
                        <pre>Researchgate: <a href="https://www.researchgate.net/profile/Alexandre_Santos10" target="_blank">https://www.researchgate.net/profile/Alexandre_Santos10</a>                       <u></u><u></u></pre>
                        <pre>LinkedIn: <a href="https://br.linkedin.com/in/alexandre-dos-santos-87961635" target="_blank">https://br.linkedin.com/in/alexandre-dos-santos-87961635</a><u></u><u></u></pre>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </blockquote>
      </div>
      <br>
      <br>
      <hr style="border:none;color:#909090;background-color:#b0b0b0;min-height:1px;width:99%">
      <table style="border-collapse:collapse;border:none">
        <tbody>
          <tr>
            <td style="border:none;padding:0px 15px 0px 8px"> <a href="https://www.avast.com/antivirus" target="_blank"> <img alt="Avast logo" border="0"> </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" target="_blank">www.avast.com</a>
              </p>
            </td>
          </tr>
        </tbody>
      </table>
      <br>
      <br>
      <fieldset></fieldset>
      <br>
      </div></div><span class=""><pre>_______________________________________________
R-br mailing list
<a href="mailto:R-br@listas.c3sl.ufpr.br" target="_blank">R-br@listas.c3sl.ufpr.br</a>
<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>
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.</pre>
    </span></blockquote>
    <br>
  </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" rel="noreferrer" 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" rel="noreferrer" 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></div>