[英]rbind calendar data from Web - list error
I am trying to import calendar dates in R. I found a website with dates that I imported with XML
. 我试图在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)
Get rid of some unecessary elements 摆脱一些不必要的元素
tables = tables[-1]
tables = tables[-1]
tables = tables[-13]
Generate list names 产生清单名称
names(tables) <- paste('month', 1:12, sep = '')
with a solution proposed here 在这里提出解决方案
mtables = mapply(cbind, tables, 'Month'= 1:12, SIMPLIFY=F)
Here when I want to rbind
my list: 在这里,当我想
rbind
我的列表:
do.call('rbind', mtables)
I get an error: 我收到一个错误:
Error in match.names(clabs, names(xi)) :
match.names(clabs,names(xi))中的错误:
names do not match previous names名称与以前的名称不匹配
Could you help with solve this error problem ? 您能帮助解决这个错误问题吗?
rbind normally takes two parameters. rbind通常采用两个参数。 here is a code snippet using rbind.
这是使用rbind的代码段。 hope this helps.
希望这可以帮助。 cheers oliver
欢呼的奥利弗
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)
The issue was actually in the header
. 问题实际上在
header
。
`tables = readHTMLTable(u, header = F)`
instead of 代替
`tables = readHTMLTable(u, header = T)`
In order to get the same column names for each lists. 为了得到每个列表相同的列名。
Thanks 谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.