<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Obrigado Éder,<br>
<br>
Na verdade não tinha atentado a isso, mas agora deu outro
erro, sendo:<br>
<br>
Error in apply(results, 1, function(x) { : <br>
dim(X) must have a positive length<br>
> str(tableFE99)<br>
Error in head(tableFE99) : objeto 'tableFE99' não encontrado<br>
<br>
<br>
O CRM que estou usando é:<br>
<br>
### <code r><br>
require(RCurl); require(XML)<br>
<br>
## Função de leitura da tabela<br>
readFE<- function (x, URL = ""){<br>
url0 <- URL<br>
url1 <- gsub("(^.*)(/s/.*)(\\?.*$)",
"https://dl.dropboxusercontent.com\\2", url0); url1<br>
page <- getURL(url1)<br>
classes <- c(rep("factor", 6), rep("numeric", 4), "factor")<br>
tableFE <- readHTMLTable(page, head=T,
colClasses=classes)[[1]] <br>
x<-NULL<br>
results <- x<br>
results <- x<br>
results<-results[!apply(results,1,function(x){any(x=="(NULL)")}),]<br>
results<-subset(results, !(latitude == "0.00000000" |
longitude == "0.00000000"))<br>
results<br>
}<br>
#--#<br>
<br>
## Tentativa de leitura da tabela <br>
tableFE99<-readFE(URL=<a class="moz-txt-link-rfc2396E" href="https://www.dropbox.com/s/foeh9oqbiqlawvg/TALHOES_AGENTE2.htm?dl=1">"https://www.dropbox.com/s/foeh9oqbiqlawvg/TALHOES_AGENTE2.htm?dl=1"</a>)<br>
str(tableFE99)<br>
### </code><br>
<br>
<br>
<br>
<br>
<br>
<br>
<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 30/01/2016 14:43, Éder Comunello
escreveu:<br>
</div>
<blockquote
cite="mid:CABmC8g=NUONWUcmEKwnzqiv5We6RmEN5o=u8jjySVgZytSYDFg@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_default"
style="font-family:verdana,sans-serif">Senhores, boa tarde!</div>
<div class="gmail_default"
style="font-family:verdana,sans-serif"><br>
</div>
<div class="gmail_default"
style="font-family:verdana,sans-serif">Na forma que sugeri é
necessário alterar o link "default" do dropbox pra acessar
diretamente o arquivo.</div>
<div class="gmail_default"
style="font-family:verdana,sans-serif"><br>
</div>
<div class="gmail_default">
<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/foeh9oqbiqlawvg/TALHOES_AGENTE2.htm?dl=1"
target="_blank">https://www.dropbox.com/s/foeh9oqbiqlawvg/TALHOES_AGENTE2.htm?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" target="_blank"><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"><br>
</font></div>
<div class="gmail_default"><font face="monospace, monospace">page
<- getURL(url1)</font></div>
<div class="gmail_default"><font face="monospace, monospace">#
page <- getURL(url1, ssl.verifypeer = FALSE)</font><br>
</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)</font></div>
<div class="gmail_default"><font face="monospace, monospace">###
</code></font></div>
</div>
<div class="gmail_extra"><br clear="all">
<div>
<div>
<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>
<br>
<div class="gmail_quote">Em 30 de janeiro de 2016 12:17, Paulo
Nogueira Starzynski <span dir="ltr"><<a
moz-do-not-send="true" href="mailto:paulons@gmail.com"
target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:paulons@gmail.com">paulons@gmail.com</a></a>></span>
escreveu:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr">Alexandre,
<div>no teste que fiz aqui, o problema é na leitura da
tabela. A função getURL não está retornando conteúdo
que a função readHTMLTable possa extrair.</div>
<div><br>
</div>
<div><span style="border-collapse:separate;color:rgb(0,0,0);font-family:'Ubuntu Mono';font-size:14px;line-height:16px;white-space:pre-wrap;border-spacing:0px;background-color:rgb(225,226,229)"><pre style="font-family:'Ubuntu Mono';outline:none;border:none;margin-top:0px;margin-bottom:0px;line-height:1.2;font-size:10.4pt!important;white-space:pre-wrap!important"><span style="white-space:pre-wrap;color:blue">> </span><span style="color:blue">URL="<a moz-do-not-send="true" href="https://www.dropbox.com/s/foeh9oqbiqlawvg/TALHOES_AGENTE2.htm?dl=1" target="_blank">https://www.dropbox.com/s/foeh9oqbiqlawvg/TALHOES_AGENTE2.htm?dl=1</a>"
</span><span style="white-space:pre-wrap;color:blue">> </span><span style="color:blue">page <- RCurl::getURL(URL)
</span><span style="white-space:pre-wrap;color:blue">> </span><span style="color:blue">page
</span>[1] "<html>\r\n <head><title>Found</title></head>\r\n <body>\r\n <h1>Found</h1>\r\n <p>The resource was found at <a href=\"<a moz-do-not-send="true" href="https://dl.dropboxusercontent.com/content_link/tkauy9obP7pgxKYpb9j5ZR2LCSUTe2iJpaULTWEN4RzdfR6AtirbNWGtt8q9Ncex/file?dl=1%5C" target="_blank">https://dl.dropboxusercontent.com/content_link/tkauy9obP7pgxKYpb9j5ZR2LCSUTe2iJpaULTWEN4RzdfR6AtirbNWGtt8q9Ncex/file?dl=1\</a>"><a moz-do-not-send="true" href="https://dl.dropboxusercontent.com/content_link/tkauy9obP7pgxKYpb9j5ZR2LCSUTe2iJpaULTWEN4RzdfR6AtirbNWGtt8q9Ncex/file?dl=1" target="_blank">https://dl.dropboxusercontent.com/content_link/tkauy9obP7pgxKYpb9j5ZR2LCSUTe2iJpaULTWEN4RzdfR6AtirbNWGtt8q9Ncex/file?dl=1</a></a>;\r\nyou should be redirected automatically.\r\n\r\n<!-- --></p>\r\n <hr noshade>\r\n <div align=\"right\">WSGI Server</div>\r\n </body>\r\n</ht
ml>\r\n"</pre></span></div>
</div>
<div class="gmail_extra"><br clear="all">
<div>
<div>
<div dir="ltr">
<div>
<div>Abraços,<br>
</div>
<div>Paulo<br>
</div>
</div>
</div>
</div>
</div>
<br>
<div class="gmail_quote">
<div>
<div>Em 30 de janeiro de 2016 12:16, ASANTOS <span
dir="ltr"><<a moz-do-not-send="true"
href="mailto:alexandresantosbr@yahoo.com.br"
target="_blank">alexandresantosbr@yahoo.com.br</a>></span>
escreveu:<br>
</div>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px
0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div>
<div>
<div bgcolor="#FFFFFF" text="#000000"> Bom dia
Éder,<br>
<br>
<br>
Tentei criar uma função com os comandos
de leitura da tabela em HTML e também não
funfou, posso pedir novamente sua ajuda,
Obrigado,<br>
<br>
<br>
<br>
## Função de leitura da tabela<span><br>
readFE<- function (x, URL = ""){<br>
<br>
</span> page <- getURL(URL)<span><br>
classes <- c(rep("factor", 6),
rep("numeric", 4), "factor")<br>
tableFE <- readHTMLTable(page, head=T,
colClasses=classes)[[1]] <br>
</span><span> x<-NULL<br>
results <- x<br>
</span><span> results <- x<br>
results<-results[!apply(results,1,function(x){any(x=="(NULL)")}),]<br>
</span> results<-subset(results,
!(latitude == "0.00000000" | longitude ==
"0.00000000"))<br>
results<br>
}<br>
#--#<br>
<br>
<br>
<br>
<br>
<br>
## Tentativa de leitura da tabela <br>
tableFE<-readFE(URL=<a
moz-do-not-send="true"
href="https://www.dropbox.com/s/foeh9oqbiqlawvg/TALHOES_AGENTE2.htm?dl=1"
target="_blank"><a class="moz-txt-link-rfc2396E" href="https://www.dropbox.com/s/foeh9oqbiqlawvg/TALHOES_AGENTE2.htm?dl=1">"https://www.dropbox.com/s/foeh9oqbiqlawvg/TALHOES_AGENTE2.htm?dl=1"</a></a>)<br>
head(tableFE)<br>
#---------------<span><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 moz-do-not-send="true" href="tel:%28%2B55%29%2065%208132-8112" value="+556581328112" target="_blank">(+55) 65 8132-8112</a> (TIM) <a moz-do-not-send="true" href="tel:%28%2B55%29%2065%209686-6970" value="+556596866970" target="_blank">(+55) 65 9686-6970</a> (VIVO)
<a moz-do-not-send="true" href="mailto:e-mails:alexandresantosbr@yahoo.com.br" target="_blank">e-mails:alexandresantosbr@yahoo.com.br</a>
<a moz-do-not-send="true" href="mailto:alexandre.santos@cas.ifmt.edu.br" target="_blank">alexandre.santos@cas.ifmt.edu.br</a>
Lattes: <a moz-do-not-send="true" href="http://lattes.cnpq.br/1360403201088680" target="_blank">http://lattes.cnpq.br/1360403201088680</a>
OrcID: <a moz-do-not-send="true" href="http://orcid.org/0000-0001-8232-6722" target="_blank">orcid.org/0000-0001-8232-6722</a>
Researchgate: <a moz-do-not-send="true" href="https://www.researchgate.net/profile/Alexandre_Santos10" target="_blank">https://www.researchgate.net/profile/Alexandre_Santos10</a>
LinkedIn: <a moz-do-not-send="true" 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>
<div>Em 29/01/2016 08:41, Éder Comunello
escreveu:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div>
<div><font face="verdana,
sans-serif">Alexandre, bom dia!</font></div>
<div><font face="verdana,
sans-serif"><br>
</font></div>
<div><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><br>
</div>
<div><font face="verdana,
sans-serif"><br>
</font></div>
<div><font face="monospace,
monospace">### <code r></font></div>
<div><font face="monospace,
monospace">require(RCurl);
require(XML)</font></div>
<div><font face="monospace,
monospace">url0 <- "<a
moz-do-not-send="true"
href="https://www.dropbox.com/s/znmr0lwda2y6fc5/BD_teste2.html?dl=1"
target="_blank"><a class="moz-txt-link-freetext" href="https://www.dropbox.com/s/znmr0lwda2y6fc5/BD_teste2.html?dl=1">https://www.dropbox.com/s/znmr0lwda2y6fc5/BD_teste2.html?dl=1</a></a>"</font></div>
<div><font face="monospace,
monospace">url1 <-
gsub("(^.*)(/s/.*)(\\?.*$)", "<a
moz-do-not-send="true"
href="https://dl.dropboxusercontent.com"
target="_blank"><a class="moz-txt-link-freetext" href="https://dl.dropboxusercontent.com">https://dl.dropboxusercontent.com</a></a>\\2",
url0); url1</font></div>
<div><font face="monospace,
monospace"># [1] "<a
moz-do-not-send="true"
href="https://dl.dropboxusercontent.com/s/znmr0lwda2y6fc5/BD_teste2.html"
target="_blank"><a class="moz-txt-link-freetext" href="https://dl.dropboxusercontent.com/s/znmr0lwda2y6fc5/BD_teste2.html">https://dl.dropboxusercontent.com/s/znmr0lwda2y6fc5/BD_teste2.html</a></a>"</font></div>
<div><font face="monospace,
monospace"><br>
</font></div>
<div><font face="monospace,
monospace">page <-
getURL(url1)</font></div>
<div><font face="monospace,
monospace">tableFE <-
readHTMLTable(page, head=T)[[1]]</font></div>
<div><font face="monospace,
monospace">str(tableFE) ###
todas variáveis estão como
fatores - corrigir!</font></div>
<div><font face="monospace,
monospace"><br>
</font></div>
<div><font face="monospace,
monospace">classes <-
c(rep("factor", 6),
rep("numeric", 4), "factor")</font></div>
<div><font face="monospace,
monospace">tableFE <-
readHTMLTable(page, head=T,
colClasses=classes)[[1]]</font></div>
<div><font face="monospace,
monospace">str(tableFE) ### OK!</font></div>
<div><font face="monospace,
monospace">head(tableFE)</font></div>
<div><font face="monospace,
monospace"><br>
</font></div>
<div><font face="monospace,
monospace">##Agregando os
resultados</font></div>
<div><font face="monospace,
monospace">aggPestFE <-
function(db=tableFE,
key="descricao"){</font></div>
<div><font face="monospace,
monospace">lista <-
split(db, db[key])</font></div>
<div><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><font face="monospace,
monospace">return(result)</font></div>
<div><font face="monospace,
monospace">}</font></div>
<div><font face="monospace,
monospace"><br>
</font></div>
<div><font face="monospace,
monospace">### Devido aos
"defaults", obtém mesmos
resultados nas três formas que
seguem:</font></div>
<div><font face="monospace,
monospace">aggPestFE()[5]</font></div>
<div><font face="monospace,
monospace">aggPestFE(tableFE)[5]</font></div>
<div><font face="monospace,
monospace">aggPestFE(tableFE,
"descricao")[5]</font></div>
<div><font face="monospace,
monospace"># $`Lagartas
Desfolhadoras`</font></div>
<div><font face="monospace,
monospace"># Group.1
Group.2 Group.3 formiga_area
qtd_destruido</font></div>
<div><font face="monospace,
monospace"># 1 GN
Chale 26 0
62.5</font></div>
<div><font face="monospace,
monospace"># 2 RD Corrego
da Coruja 26 0
50.0</font></div>
<div><font face="monospace,
monospace"># 3 GN
Aeroporto II 28
0 75.0</font></div>
<div><font face="monospace,
monospace"><br>
</font></div>
<div><font face="monospace,
monospace">### </code></font></div>
</div>
<div class="gmail_extra"><br
clear="all">
<div>
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr"><font
style="font-size:small"
face="arial,
helvetica,
sans-serif">
<div></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>
</div>
</div>
</div>
<br>
</div>
</div>
<span>_______________________________________________<br>
R-br mailing list<br>
<a moz-do-not-send="true"
href="mailto:R-br@listas.c3sl.ufpr.br"
target="_blank">R-br@listas.c3sl.ufpr.br</a><br>
<a moz-do-not-send="true"
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 moz-do-not-send="true"
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>
</span></blockquote>
</div>
<br>
</div>
<br>
_______________________________________________<br>
R-br mailing list<br>
<a moz-do-not-send="true"
href="mailto:R-br@listas.c3sl.ufpr.br" target="_blank">R-br@listas.c3sl.ufpr.br</a><br>
<a moz-do-not-send="true"
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 moz-do-not-send="true"
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>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
R-br mailing list
<a class="moz-txt-link-abbreviated" href="mailto:R-br@listas.c3sl.ufpr.br">R-br@listas.c3sl.ufpr.br</a>
<a class="moz-txt-link-freetext" href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br">https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br</a>
Leia o guia de postagem (<a class="moz-txt-link-freetext" href="http://www.leg.ufpr.br/r-br-guia">http://www.leg.ufpr.br/r-br-guia</a>) e forne�a c�digo m�nimo reproduz�vel.</pre>
</blockquote>
<br>
</body>
</html>