ropensci / weathercan

R package for downloading weather data from Environment and Climate Change Canada
https://docs.ropensci.org/weathercan
GNU General Public License v3.0
102 stars 29 forks source link

weather_dl throws error ` 'names' attribute [25] must be the same length as the vector [24]` #52

Closed joethorley closed 6 years ago

joethorley commented 6 years ago

Expected Behavior

weather_dl should return weather data

Current Behavior

weather_dl errors out

Steps to Reproduce (for bugs)

Using GitHub PAT from envvar GITHUB_PAT
Downloading GitHub repo ropensci/weathercan@master
from URL https://api.github.com/repos/ropensci/weathercan/zipball/master
Installing weathercan
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ --no-save  \
  --no-restore --quiet CMD INSTALL  \
  '/private/var/folders/48/q6ltldjs251000_wvjrdy_vm0000gn/T/Rtmp2j8c0e/devtoolse0ba9742238/ropensci-weathercan-0eafb91'  \
  --library='/Library/Frameworks/R.framework/Versions/3.5/Resources/library' --install-tests 

* installing *source* package ‘weathercan’ ...
** R
** data
*** moving datasets to lazyload DB
** inst
** tests
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (weathercan)
> library(weathercan)
> kam.pg <- weather_dl(station_ids = c(48248, 51423),
+                       start = "2016-01-01", end = "2016-02-15")
Error in names(w) <- n : 
  'names' attribute [25] must be the same length as the vector [24]

Your Environment

> devtools::session_info()
Session info -----------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.5.0 (2018-04-23)
 system   x86_64, darwin15.6.0        
 ui       RStudio (1.1.442)           
 language (EN)                        
 collate  en_CA.UTF-8                 
 tz       America/Vancouver           
 date     2018-05-10                  

Packages ---------------------------------------------------------------------------------------
 package    * version date       source                              
 assertthat   0.2.0   2017-04-11 CRAN (R 3.5.0)                      
 base       * 3.5.0   2018-04-24 local                               
 bindr        0.1.1   2018-03-13 CRAN (R 3.5.0)                      
 bindrcpp   * 0.2.2   2018-03-29 CRAN (R 3.5.0)                      
 compiler     3.5.0   2018-04-24 local                               
 curl         3.2     2018-03-28 CRAN (R 3.5.0)                      
 datasets   * 3.5.0   2018-04-24 local                               
 devtools     1.13.5  2018-02-18 CRAN (R 3.5.0)                      
 digest       0.6.15  2018-01-28 CRAN (R 3.5.0)                      
 dplyr        0.7.4   2017-09-28 CRAN (R 3.5.0)                      
 git2r        0.21.0  2018-01-04 CRAN (R 3.5.0)                      
 glue         1.2.0   2017-10-29 CRAN (R 3.5.0)                      
 graphics   * 3.5.0   2018-04-24 local                               
 grDevices  * 3.5.0   2018-04-24 local                               
 httr         1.3.1   2017-08-20 CRAN (R 3.5.0)                      
 knitr        1.20    2018-02-20 CRAN (R 3.5.0)                      
 lubridate    1.7.4   2018-04-11 CRAN (R 3.5.0)                      
 magrittr     1.5     2014-11-22 CRAN (R 3.5.0)                      
 memoise      1.1.0   2017-04-21 CRAN (R 3.5.0)                      
 methods    * 3.5.0   2018-04-24 local                               
 pillar       1.2.2   2018-04-26 CRAN (R 3.5.0)                      
 pkgconfig    2.0.1   2017-03-21 CRAN (R 3.5.0)                      
 purrr        0.2.4   2017-10-18 CRAN (R 3.5.0)                      
 R6           2.2.2   2017-06-17 CRAN (R 3.5.0)                      
 Rcpp         0.12.16 2018-03-13 CRAN (R 3.5.0)                      
 rlang        0.2.0   2018-02-20 CRAN (R 3.5.0)                      
 stats      * 3.5.0   2018-04-24 local                               
 stringi      1.2.2   2018-05-02 CRAN (R 3.5.0)                      
 stringr      1.3.0   2018-02-19 CRAN (R 3.5.0)                      
 tibble       1.4.2   2018-01-22 CRAN (R 3.5.0)                      
 tidyr        0.8.0   2018-01-29 CRAN (R 3.5.0)                      
 tidyselect   0.2.4   2018-02-26 CRAN (R 3.5.0)                      
 tools        3.5.0   2018-04-24 local                               
 utils      * 3.5.0   2018-04-24 local                               
 weathercan * 0.2.5   2018-05-10 Github (ropensci/weathercan@0eafb91)
 withr        2.1.2   2018-03-15 CRAN (R 3.5.0)                      
 yaml         2.1.19  2018-05-01 CRAN (R 3.5.0)    
joethorley commented 6 years ago
> traceback()
2: weather_format(w = w, interval = interval, tz_disp = tz_disp, 
       string_as = string_as, quiet = quiet, preamble = preamble)
1: weather_dl(station_ids = c(48248, 51423), start = "2016-01-01", 
       end = "2016-02-15")
steffilazerte commented 6 years ago

Thanks for opening the issue! I'm on vacation with no computer but I'll look into it when I get back.

steffilazerte commented 6 years ago

Okay, figured it out.

ECCC updated the file format by omitting a column. I've created a fix that addresses this issue in particular, and which should also make the package more robust to any future changes. Just to make sure I've also included some extra testing suites that should alert me to specific problems, without disrupting users.

The fix is on the dev-steffi branch, if you have a chance to check it out, that'd be great!

joethorley commented 6 years ago

I can confirm that has fixed the issue

Thanks