我正在尝试编写一个循环来执行readHTMLTable(),通过公式提供的连续日期列表。我已成功导入日期之间的所有数据。但是,该数据并不包含日期列,因此使用我提供循环的日期序列,我希望循环读取HTML表格,然后添加一个新列以及用于该迭代的日期。在日期列表中使用readHTMLTable并使用数据创建新日期列
这是我到目前为止有:
library(XML)
library(RCurl)
library(plyr)
# create the days
x
# create a url template for sprintf()
utmp
# convert to numeric matrix after splitting for year, month, day
m
# create the list to hold the results
tables
# get the tables
for(i in seq_len(nrow(m))) {
# create the url for the day and if it exists, read it - if not, NULL
tables[[i]]
readHTMLTable(u, stringsAsFactors = FALSE)
else NULL
}
data
所以基本上,我想我的最终数据帧以特色m一个名为像data$Date新列。
感谢您的帮助,如果您需要澄清,请告诉我!
2016-01-25
medavis6
+0
如果循环中没有'Sys.sleep',那么您违反了网站的[服务条款](http://www.sports-reference.com/termsofuse.shtml)。 –