skoval / deuce

R package for web scraping of tennis data
89 stars 23 forks source link

rbind error in fetching repo data in make.R - names do not match previous names #9

Closed ellisp closed 4 years ago

ellisp commented 4 years ago

When running make.R I get as far as this problem:

> atp_rankings <- do.call("rbind", lapply(grep("rankings_[0-9]", files, val = T), function(x) fetch_repo_data(x, strings = FALSE, header = T, quote = "")))
Error in match.names(clabs, names(xi)) : 
  names do not match previous names

> traceback(max.lines = 20)
5: stop("names do not match previous names")
4: match.names(clabs, names(xi))
3: rbind(deparse.level, ...)
2: rbind(list(ranking_date = c(20000110L, 20000110L, 20000110L, 
   20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 
   20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 
   20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 
   20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 
   20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 
   20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 
   20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 
   20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 
   20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 
   20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 
   20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 
   20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 
   20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 
   20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 
   20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 
   20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 
   20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 
   20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 
   20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 20000110L, 
    ...
1: do.call("rbind", lapply(grep("rankings_[0-9]", files, val = T), 
       function(x) fetch_repo_data(x, strings = FALSE, header = T, 
           quote = "")))
skoval commented 4 years ago

It looks like the 10s and 90s rankings files had no header! This was causing the rbind error because the colnames of the read.csv wasn't the same for all of the ranking files. I've pushed a change that worked on my system, it only affects the content of make.R. The code its a bit uglier now but not much we can do when the file structures aren't consistent :(

ellisp commented 4 years ago

Thanks, works for me now.