从Web列表中绑定日历数据错误



我正在尝试在R中导入日历日期。我找到了一个网站,上面有我用XML导入的日期。

library('XML')
u="http://www.timeanddate.com/calendar/custom.html?year=2015&country=5&typ=0&display=2&cols=0&hol=0&cdt=1&holm=1&df=1"
tables = readHTMLTable(u)

去掉一些不需要的元素

tables = tables[-1]
tables = tables[-1]
tables = tables[-13]

生成列表名称

names(tables) <- paste('month', 1:12, sep = '')

和这里提出的解决方案

mtables = mapply(cbind, tables, 'Month'= 1:12, SIMPLIFY=F)

这里当我想要rbind我的列表:

do.call('rbind', mtables)

我得到一个错误:

match.names(clabs, names(xi))错误:
名称与前面的名称不匹配

你能帮忙解决这个错误问题吗?

rbind通常接受两个参数。下面是使用rbind的代码片段。希望这对你有所帮助。干杯奥利弗

vehicles1 <- unique(grep("Vehicles", SCC$EI.Sector, ignore.case = TRUE, value = TRUE)) 
vehicles <- SCC[SCC$EI.Sector %in% vehicles1, ]["SCC"]
# Select observations relating to Baltimore MD
vehiclesBaltimore <- NEI[NEI$SCC %in% vehicles$SCC & NEI$fips == "24510",]
# Select observations relating to Los Angeles County CA
vehiclesLosAngelesCounty <- NEI[NEI$SCC %in% vehicles$SCC & NEI$fips == "06037",]
# Merge observations of Baltimore and Los Angeles County
vehiclesCompare <- rbind(vehiclesBaltimore, vehiclesLosAngelesCounty)

问题实际上是在header

`tables = readHTMLTable(u, header = F)`

代替

`tables = readHTMLTable(u, header = T)` 

,以便为每个列表获得相同的列名。

谢谢

最新更新