Error saying "'names' attribute [27] must be the same length as the vector [21]"

0 votes

I'm running into a problem when trying to use the readHTMLTable function in the R package XML. When running

library(XML)
baseurl <- "http://www.pro-football-reference.com/teams/"
team <- "nwe"
year <- 2011
theurl <- paste(baseurl,team,"/",year,".htm",sep="")

readurl <- getURL(theurl)
readtable <- readHTMLTable(readurl)

I get the error message:

Error in names(ans) = header : 
'names' attribute [27] must be the same length as the vector [21]
Nov 12, 2018 in Data Analytics by Ali
• 10,430 points
287 views

1 answer to this question.

0 votes

When you end up with this error its obvious that it's having trouble matching the data with what it's parsed for header values. The simplest way around this is to simply turn off header parsing entirely:

table.list <- readHTMLTable(theurl, header=F)
answered Nov 12, 2018 by Maverick
• 10,040 points

Related Questions In Data Analytics

0 votes
1 answer

Error saying "duplicate 'row.names' are not allowed" when trying to setup my data for the mlogit-package

Take out the chid.var argument in your call to mlogit.data, ...READ MORE

answered Nov 12, 2018 in Data Analytics by Maverick
• 10,040 points
276 views
0 votes
1 answer

Error saying "vector size cannot be NA" when using R with data mining

You can use the removesparseterm function.  Removes sparse ...READ MORE

answered Nov 15, 2018 in Data Analytics by Maverick
• 10,040 points
463 views
0 votes
1 answer

Plot two variables as lines on the same graph using ggplot

If you have small number of variables, ...READ MORE

answered Apr 17, 2018 in Data Analytics by kappa3010
• 2,020 points
1,038 views
0 votes
1 answer
0 votes
1 answer

": cannot open the connection" Error in R

There can be two reasons for this ...READ MORE

answered Oct 31, 2018 in Data Analytics by Kalgi
• 41,620 points
519 views
0 votes
1 answer

“subscript out of bounds” Error in r programming

This error is likely to occur when ...READ MORE

answered Oct 31, 2018 in Data Analytics by Kalgi
• 41,620 points
1,775 views
0 votes
1 answer

What does “replacement has” Error mean?

This error occurs when one tries to ...READ MORE

answered Oct 31, 2018 in Data Analytics by Kalgi
• 41,620 points
45 views
0 votes
1 answer

Errors saying "Error: unexpected '}' in "}"

This is a syntax error: Enclose your if ...READ MORE

answered Nov 8, 2018 in Data Analytics by Maverick
• 10,040 points
417 views
0 votes
1 answer
+1 vote
1 answer

Error saying "The following signatures couldn't be verified because the public key is not available: NO_PUBKEY"

Try this: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ...READ MORE

answered Nov 12, 2018 in Data Analytics by Maverick
• 10,040 points
104 views