简体   繁体   English

readHTMLTable使用readHTMLTable

[英]readHTMLTable using readHTMLTable

I'm trying to read in a table into R for this link: http://www.insidestocks.com/optqte.asp?sym=ESU4&view=add&mode=d 我正试图在表中读到R链接: http//www.insidestocks.com/optqte.asp?sym = ESU4& view = add& mode = d

My R code is below. 我的R代码如下。 For some reason it is not recognizing the table. 由于某种原因,它无法识别表格。 Perhaps there is a better package for me to use to do this? 也许有一个更好的方案供我这样做? Any help would be appreciated! 任何帮助,将不胜感激!

library(XML)
theurl <- "http://www.insidestocks.com/optqte.asp?sym=ESU4&view=add&mode=d"
tables <- readHTMLTable(theurl)
n.rows <- unlist(lapply(tables, function(t) dim(t)[1]))
tables[[whictablesh.max(n.rows)]]

The relevant one is the seventh table. 相关的是第七个表。

tables[[7]]

And we get 我们得到了

Strike Open    High     Low    Close Change Volume Open Int Prem ($)
1 600.00C      1247.75 1243.20 1243.25s  +9.75      0      202 62162.50
2 600.00P         0.05    0.01    0.01s   unch      0        0     0.50
3 625.00C      1222.75 1218.20 1218.25s  +9.75      0      202 60912.50
4 625.00P         0.05    0.01    0.01s   unch      0        0     0.50
5 650.00C      1197.75 1193.20 1193.25s  +9.75      0        0 59662.50

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM