Btibert3
Btibert3

Reputation: 40146

Read HTML Table in R - Troubleshooting

I have seen a number of posts here that describe how to parse HTML tables using the XML package. That said, I have got my code to work except that my first data row gets read in as my column names.

My code is taken from the answser at this link

How can I get around this?

Many thanks,

Brock

Upvotes: 1

Views: 6098

Answers (1)

bnaul
bnaul

Reputation: 17636

From the XML package documentation for "readHTMLTable":

header: either a logical value indicating whether the table has
          column labels, e.g. the first row or a ‘thead’, or
          alternatively a character vector giving the names to use for
          the resulting columns.

So running the same command but passing in header=FALSE should do what you want. Alternatively, if you have a vector of column names you want to use instead, you can use header=your_vector_of_column_names to set the column names instead of setting them to empty strings.

Upvotes: 3

Related Questions