我想知道我们是否可以使用readr包来访问html表,其中包含发布html表的页面的url。例如,我想在page上导入要加载到R的表。
答案 0 :(得分:5)
我不确定'chizamp'可能是什么,但是Scriven是正确的,虽然需要一些额外的noodling来确定> library(XML)
> help(pack=XML)
> sports <- readHTMLTable("http://sports.yahoo.com/nfl/stats/byteam?group=Offense&cat=Total&conference=NFL&year=season_2010&sort=530&old_category=Total&old_group=Offense")
> str(sports[[1]])
'data.frame': 1 obs. of 2 variables:
$ V1: Factor w/ 1 level "": 1
$ V2: Factor w/ 1 level "Search SportsSearch Web": 1
> str(sports[[2]])
'data.frame': 2 obs. of 1 variable:
$ : Factor w/ 2 levels "","Sortable Stats": 2 1
> length(sports)
[1] 8
> str(sports[[8]])
NULL
# top of str() on the seventh item in that list
str(sports[[7]])
'data.frame': 32 obs. of 28 variables:
$ Team : Factor w/ 32 levels "Arizona Cardinals",..: 19 26 24 14 2 23 21 9 13 12 ...
$ : Factor w/ 1 level "": 1 1 1 1 1 1 1 1 1 1 ...
$ G : Factor w/ 1 level "16": 1 1 1 1 1 1 1 1 1 1 ...
$ : Factor w/ 1 level "": 1 1 1 1 1 1 1 1 1 1 ...
$ Pts/G : Factor w/ 28 levels "12.3","16.9",..: 28 27 26 25 24 23 22 22 21 20 ...
返回的多个表中的哪一个可能是你想要的那个:
angularModule