Reputation: 127
This is the table I am trying to scrape from online into R
What is happening when I run the following code is the first row of the table is getting cut off- for example, the table starts with Justin Tucker instead of Steven Gotskowski.
library(XML)
kicker_1<- paste("http://www.nfl.com/stats/categorystats?archive=false&conference=null&statisticPositionCategory=FIELD_GOAL_KICKER&season=2013&seasonType=REG&experience=&tabSeq=1&qualified=false&Submit=Go")
kickers_13<- readHTMLTable(kicker_1)
from this point, the first row of the table is cut off, is there something in my link I need to fix?
Upvotes: 0
Views: 627
Reputation: 99331
The problem you're having is a bit strange. I got the first line by adjusting the header
argument to FALSE
. Unfortunately, you'll probably have to manually fill in the column names.
library(XML)
url <- "http://www.nfl.com/stats/categorystats?archive=false&conference=null&statisticPositionCategory=FIELD_GOAL_KICKER&season=2013&seasonType=REG&experience=&tabSeq=1&qualified=false&Submit=Go"
x <- readHTMLTable(url, header = FALSE, which = 1)
head(x)
## V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 V17 V18 V19 V20 V21 V22 V23
## 1 1 Stephen Gostkowski NE K 38 41 93 0 54 1-1 100 8-8 100 13-13 100 13-11 85 6-5 83 44 44 100 0
## 2 1 Justin Tucker BAL K 38 41 93 0 61 0-0 0 10-10 100 13-12 92 11-10 91 7-6 86 26 26 100 0
## 3 3 Adam Vinatieri IND K 35 40 88 1 52 0-0 0 6-6 100 11-10 91 17-15 88 6-4 67 34 34 100 0
## 4 4 Nick Novak SD K 34 37 92 2 50 1-1 100 9-9 100 16-13 81 9-9 100 2-2 100 42 42 100 0
## 5 5 Dan Carpenter BUF K 33 36 92 0 55 0-0 0 13-13 100 6-6 100 11-10 91 6-4 67 32 32 100 0
## 6 5 Mason Crosby GB K 33 37 89 0 57 1-1 100 13-13 100 8-8 100 8-6 75 7-5 71 42 42 100 0
Upvotes: 3