<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Muito obrigado Éder!!!<br>
    <br>
          Problema resolvido!!!<br>
    <br>
    Abraços,<br>
    <pre class="moz-signature" 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: (+55) 65 8132-8112 (TIM)   (+55) 65 9686-6970 (VIVO)
<a class="moz-txt-link-abbreviated" href="mailto:e-mails:alexandresantosbr@yahoo.com.br">e-mails:alexandresantosbr@yahoo.com.br</a> 
        <a class="moz-txt-link-abbreviated" href="mailto:alexandre.santos@cas.ifmt.edu.br">alexandre.santos@cas.ifmt.edu.br</a> 
Lattes: <a class="moz-txt-link-freetext" href="http://lattes.cnpq.br/1360403201088680">http://lattes.cnpq.br/1360403201088680</a>
OrcID: orcid.org/0000-0001-8232-6722 
Researchgate: <a class="moz-txt-link-freetext" href="https://www.researchgate.net/profile/Alexandre_Santos10">https://www.researchgate.net/profile/Alexandre_Santos10</a>                       
LinkedIn: <a class="moz-txt-link-freetext" href="https://br.linkedin.com/in/alexandre-dos-santos-87961635">https://br.linkedin.com/in/alexandre-dos-santos-87961635</a>
======================================================================
</pre>
    <div class="moz-cite-prefix">Em 29/01/2016 08:41, Éder Comunello
      escreveu:<br>
    </div>
    <blockquote
cite="mid:CABmC8gkhFX_S4GwfgdcFbc0V5nTyuGCZ6w6B1Rcz6c09XsUufw@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_default" style="">
          <div class="gmail_default"><font face="verdana, sans-serif">Alexandre,
              bom dia!</font></div>
          <div class="gmail_default"><font face="verdana, sans-serif"><br>
            </font></div>
          <div class="gmail_default"><font face="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().</font></div>
          <div class="gmail_default"><br>
          </div>
          <div class="gmail_default"><font face="verdana, sans-serif"><br>
            </font></div>
          <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 moz-do-not-send="true"
                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
              <- gsub("(^.*)(/s/.*)(\\?.*$)", "<a
                moz-do-not-send="true"
                href="https://dl.dropboxusercontent.com"><a class="moz-txt-link-freetext" href="https://dl.dropboxusercontent.com">https://dl.dropboxusercontent.com</a></a>\\2",
              url0); url1</font></div>
          <div class="gmail_default"><font face="monospace, monospace">#
              [1] "<a moz-do-not-send="true"
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">str(tableFE)
              ### todas variáveis estão como fatores - corrigir!</font></div>
          <div class="gmail_default"><font face="monospace, monospace"><br>
            </font></div>
          <div class="gmail_default"><font face="monospace, monospace">classes
              <- c(rep("factor", 6), rep("numeric", 4), "factor")</font></div>
          <div class="gmail_default"><font face="monospace, monospace">tableFE
              <- readHTMLTable(page, head=T, colClasses=classes)[[1]]</font></div>
          <div class="gmail_default"><font face="monospace, monospace">str(tableFE)
              ### OK!</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">aggPestFE
              <- function(db=tableFE, key="descricao"){</font></div>
          <div class="gmail_default"><font face="monospace, monospace">lista
               <- split(db, db[key])</font></div>
          <div class="gmail_default"><font face="monospace, monospace">result
              <- lapply(lista, function(x) aggregate(x[,7:8],
              by=list(x[,3],x[,2],x[,5]), mean))</font></div>
          <div class="gmail_default"><font face="monospace, monospace">return(result)</font></div>
          <div class="gmail_default"><font face="monospace, monospace">}</font></div>
          <div class="gmail_default"><font face="monospace, monospace"><br>
            </font></div>
          <div class="gmail_default"><font face="monospace, monospace">###
              Devido aos "defaults", obtém mesmos resultados nas três
              formas que seguem:</font></div>
          <div class="gmail_default"><font face="monospace, monospace">aggPestFE()[5]</font></div>
          <div class="gmail_default"><font face="monospace, monospace">aggPestFE(tableFE)[5]</font></div>
          <div class="gmail_default"><font face="monospace, monospace">aggPestFE(tableFE,
              "descricao")[5]</font></div>
          <div class="gmail_default"><font face="monospace, monospace">#
              $`Lagartas Desfolhadoras`</font></div>
          <div class="gmail_default"><font face="monospace, monospace">#
                Group.1           Group.2 Group.3 formiga_area
              qtd_destruido</font></div>
          <div class="gmail_default"><font face="monospace, monospace">#
              1      GN             Chale      26            0        
               62.5</font></div>
          <div class="gmail_default"><font face="monospace, monospace">#
              2      RD Corrego da Coruja      26            0        
               50.0</font></div>
          <div class="gmail_default"><font face="monospace, monospace">#
              3      GN      Aeroporto II      28            0        
               75.0</font></div>
          <div class="gmail_default"><font face="monospace, monospace"><br>
            </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 style="font-size:small"
                          face="arial, helvetica, sans-serif">
                          <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
                            style="font-size:small" face="arial,
                            helvetica, sans-serif">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>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>