ropensci-archive / bomrang

:warning: ARCHIVED :warning: Australian government Bureau of Meteorology (BOM) data client for R
Other
109 stars 26 forks source link

End year stored as character in JSON url list causes error #102

Closed ozjimbob closed 5 years ago

ozjimbob commented 5 years ago

After having installed bomrang 0.6, and having run update_station_locations(), calling the get_current_weather() function with a lat/long, an error is returned:

get_current_weather(latlon=c(-35.22061 149.04354))

Error in station_meta$end - station_meta$start : 
  non-numeric argument to binary operator`

This seems to be a result of the JSONurl_site_list.rda file storing the record end dates as character, meaning the "count" subtraction operation in the get_current_weather() return statement fails.

str(JSONurl_site_list)
...
 $ start     : num  1951 1956 1973 1997 1944 ...
 $ end       : chr  "2019" "2019" "2019" "2019" ...

Note that the only appears to be a problem after you've run update_station_locations(). The default JSONurl_site_list.rda file that comes with the package has more sensible types:

str(JSONurl_site_list)
...
 $ start     : num  1951 1956 1973 1997 1944 ...
 $ end       : int  2019 2019 2019 2019 2019 2019 2019 2019 2019 2019 ...
Session Info ```r R version 3.4.4 (2018-03-15) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 14.04.3 LTS Matrix products: default BLAS: /usr/lib/libblas/libblas.so.3.0 LAPACK: /usr/lib/lapack/liblapack.so.3.0 locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 [6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_3.4.4 tools_3.4.4 ```
adamhsparks commented 5 years ago

Whoops. They should all be integer. Thanks, I'll have a look.

adamhsparks commented 5 years ago

I did fix this, it's just not on CRAN yet. It will be in the next release that we're working up to now.

Thanks for reporting this, @ozjimbob.