使用readHTMLTable()删除行空元素(NULL)

时间:2016-01-15 18:41:05

标签: html xml r html-table

我尝试使用几乎一个空元素删除HTML表中的行,使用XLM包中的readHTMLTable()函数表示(NULL)但没有成功。在我的代码中:

require(httr)
require(XML)

读取HTML表的功能

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","character","character", 
                                       "character","character","character", 
                                       "character","character"), 
                        trim = TRUE, stringsAsFactors = FALSE 
)     
     x<-NULL
     results <- x
     x<-FE_tab[-(1),]
     results <- x
     results
}

-

为例

tableFE<-readFE(URL="https://www.dropbox.com/s/mb316ghr4irxipr/TALHOES_AGENTES.htm?dl=1")
tableFE  

有人可以帮助我吗?

谢谢,

亚历山大

0 个答案:

没有答案