我正在尝试使用R进行OECD表的webscrape
library(XML)
OECD <- readHTMLTable('http://stats.oecd.org/Index.aspx?DataSetCode=MEI_CLI')
OECD<- data.frame(rawOECD[[1]])
Run Code Online (Sandbox Code Playgroud)
我已经设法使用上面的代码获得基本表,但我无法将其变为可呈现的形式.
我很感激你的帮助.
亲切的问候,
亚当
这个怎么样?
library(XML)
OECD <- readHTMLTable('http://stats.oecd.org/Index.aspx?DataSetCode=MEI_CLI',stringsAsFactors = FALSE)
n.rows <- unlist(lapply(OECD, function(t) dim(t)[1]))
out <-as.data.frame(OECD[[which.max(n.rows)]])
colnames(out) <-c("Date",out[7,-ncol(out)]) #add row names
out <-out[-(1:9),] #clean up
Run Code Online (Sandbox Code Playgroud)