Senhores, bom dia!

Uma outra alternativa para baixar direto do dropbox...

### <code r>
require(RCurl); require(XML)
url0 <- "https://www.dropbox.com/s/znmr0lwda2y6fc5/BD_teste2.html?dl=1";
url1 <- "https://dl.dropboxusercontent.com/s/znmr0lwda2y6fc5/BD_teste2.html";

page <- getURL(url1)
tableFE <- readHTMLTable(page, head=T)[[1]]
head(tableFE)

##Agregando os resultados
lista <- split(tableFE, tableFE$descricao); head(lista)
lapply(lista, function(x) aggregate(x[,7:8], by=list(x[,2], x[,5]), mean))
### </code>

​
================================================
Éder Comunello
PhD Student in Agricultural Systems Engineering (USP/Esalq)
Brazilian Agricultural Research Corporation (Embrapa)
Dourados, MS, Brazil [22 16.5'S, 54 49.0'W]




Em 22 de janeiro de 2016 08:16, ASANTOS <[email protected]>
escreveu:

> Segue o solicitado Mauro,
>
>
> ##Pacotes e-------------------------------------------------------------
> require(httr)
> require(XML)
>
>
> ##  Função de leitura do banco de dados do APP
> #--------------------------------
> readFE<- function (x, URL = ""){
> FILE <- GET(url=URL)
>      tables <- getNodeSet(htmlParse(FILE), "//table")
>      FE_tab <- readHTMLTable(tables[[1]],
>                         header = c("empresa","desc_projeto","desc_regiao",
>
> "cadastrador_por","cod_talhao","descricao",
>
> "formiga_area","qtd_destruido","latitude",
>                                    "longitude","data_cadastro"),
>                         colClasses =
> c("character","character","character",
>                                        "character","numeric","character",
>                                        "numeric","numeric","numeric",
>                                        "numeric","character"),
>                         trim = TRUE, stringsAsFactors = FALSE
> )
>      x<-NULL
>      results <- x
>      x<-FE_tab[-(1),]
>      results <- x
>      results<-results[!apply(results,1,function(x){any(x=="(NULL)")}),]
>      results
> }
> #--#
> tableFE<-readFE(URL=
> "https://www.dropbox.com/s/znmr0lwda2y6fc5/BD_teste2.html?dl=1";
> <https://www.dropbox.com/s/znmr0lwda2y6fc5/BD_teste2.html?dl=1>)
> head(tableFE)
> #------
>
> lista <- split(tableFE, tableFE$descricao)
> lapply(lista, function(x) aggregate(x[,7:8], by=list(x[,3],x[,2],x[,5]),
> mean))
>
>
>
>
>
> --
> ======================================================================
> 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)e-mails:[email protected]
>         [email protected]
> Lattes: http://lattes.cnpq.br/1360403201088680
> OrcID: orcid.org/0000-0001-8232-6722
> Researchgate: https://www.researchgate.net/profile/Alexandre_Santos10
> LinkedIn: https://br.linkedin.com/in/alexandre-dos-santos-87961635
> ======================================================================
>
> Em 22/01/2016 03:20, Mauro Sznelwar escreveu:
>
> Pode passar o código com o data-set para rodar?
>
>
>
>
>
>
>
> Muito obrigado Éder e Manuel, faltou o pacote httr,
>
> Abraços,
>
> --
>
> ======================================================================
>
> 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)
>
> e-mails:[email protected]
>
>         [email protected]
>
> Lattes: http://lattes.cnpq.br/1360403201088680
>
> OrcID: orcid.org/0000-0001-8232-6722
>
> Researchgate: https://www.researchgate.net/profile/Alexandre_Santos10
>
> LinkedIn: https://br.linkedin.com/in/alexandre-dos-santos-87961635
>
> ======================================================================
>
> Em 21/01/2016 21:48, Éder Comunello escreveu:
>
> Alexandre,
>
>
>
> Tente a seguinte linha:
>
>
>
> lapply(lista, function(x) aggregate(x[,7:8], by=list(x[,2], x[,5]),
> mean))
>
>
> ​
>
> ================================================
> Éder Comunello
>
> PhD Student in Agricultural Systems Engineering (USP/Esalq)
>
> Brazilian Agricultural Research Corporation (Embrapa)
>
> Dourados, MS, Brazil [22 16.5'S, 54 49.0'W]
>
>
>
>
>
>
>
>
>
> Em 21 de janeiro de 2016 17:55, Manoel Galdino <[email protected]>
> escreveu:
>
> Nem consigo executar sua função de begar o banco, diz q não existe GET
>
> cheguei a carrega o pacote XML, mas tbm não funfou
>
>
>
> 2016-01-21 18:28 GMT-02:00 ASANTOS <[email protected]>:
>
> Éder,
>
>    A sua solução não funcionou com meu exemplo real e não consigo achar o
> problema, sendo que:
>
> ##  Função de leitura do banco de dados
> readFE<- function (x, URL = ""){
> FILE <- GET(url=URL)
>      tables <- getNodeSet(htmlParse(FILE), "//table")
>      FE_tab <- readHTMLTable(tables[[1]],
>                         header = c("empresa","desc_projeto","desc_regiao",
>
> "cadastrador_por","cod_talhao","descricao",
>
> "formiga_area","qtd_destruido","latitude",
>                                    "longitude","data_cadastro"),
>                         colClasses =
> c("character","character","character",
>                                        "character","numeric","character",
>                                        "numeric","numeric","numeric",
>                                        "numeric","character"),
>                         trim = TRUE, stringsAsFactors = FALSE
> )
>      x<-NULL
>      results <- x
>      x<-FE_tab[-(1),]
>      results <- x
>      results<-results[!apply(results,1,function(x){any(x=="(NULL)")}),]
>      results
> }
> #--#
> tableFE<-readFE(URL=
> <https://www.dropbox.com/s/znmr0lwda2y6fc5/BD_teste2.html?dl=1>
> "https://www.dropbox.com/s/znmr0lwda2y6fc5/BD_teste2.html?dl=1";
> <https://www.dropbox.com/s/znmr0lwda2y6fc5/BD_teste2.html?dl=1>)
> tableFE<-tableFE[1:163,1:11]
> head(tableFE)
>
> ##Agregando os resultados
> lista <- split(tableFE, tableFE$descricao)
> lapply(lista, function(x) aggregate(x[,7:8], by=list(x[,2]), mean))  ##
> Não funciona
>
>
> mas se eu faço item por item funciona e não sei porque, sendo:
>
> aggregate(lista$`Psilideo-de-Concha`[,7:8],
> by=list(lista$`Psilideo-de-Concha`[,2],lista$`Psilideo-de-Concha`[,5]),
> mean)
>
> Poderia me dar mais um help?
>
> Obrigado,
>
> Abraços
>
> --
>
> ======================================================================
>
> 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)
>
> e-mails:[email protected]
>
>         [email protected]
>
> Lattes: http://lattes.cnpq.br/1360403201088680
>
> OrcID: orcid.org/0000-0001-8232-6722
>
> Researchgate: https://www.researchgate.net/profile/Alexandre_Santos10
>
> LinkedIn: https://br.linkedin.com/in/alexandre-dos-santos-87961635
>
>
>
> ------------------------------
> [image: Avast logo] <https://www.avast.com/antivirus>
>
> Este email foi escaneado pelo Avast antivírus.
> www.avast.com <https://www.avast.com/antivirus>
>
>
>
> _______________________________________________
> R-br mailing 
> [email protected]https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br
> Leia o guia de postagem (http://www.leg.ufpr.br/r-br-guia) e forne�a c�digo 
> m�nimo reproduz�vel.
>
>
>
> _______________________________________________
> R-br mailing list
> [email protected]
> https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br
> Leia o guia de postagem (http://www.leg.ufpr.br/r-br-guia) e forneça
> código mínimo reproduzível.
>
_______________________________________________
R-br mailing list
[email protected]
https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br
Leia o guia de postagem (http://www.leg.ufpr.br/r-br-guia) e forne�a c�digo 
m�nimo reproduz�vel.

Responder a