ALShum / rwunderground

A simple R package to get historical and forecast weather data
78 stars 14 forks source link

history() and history_range() return NA values but raw JSON does not #30

Closed neilfws closed 7 years ago

neilfws commented 7 years ago

I'm using rwunderground 0.1.6, R 3.4.2 on Windows 7. This code:

h1 <- history(set_location(PWS_id = "INEWSOUT879"), date = 20170103, use_metric = TRUE)

returns a data frame where the values for viz and for all variables after the pressure column are NA.

However, the raw JSON for the same request:

http://api.wunderground.com/api/261d580a0cf44286/history_20170103/q/pws:INEWSOUT879.json

returns values for these variables. For example, the last observation for precipm is 4.3.

I see the same issue using history_range(), but not using history_daily().

Output from sessionInfo():

R version 3.4.2 (2017-09-28)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252    LC_MONETARY=English_Australia.1252
[4] LC_NUMERIC=C                       LC_TIME=English_Australia.1252    

attached base packages:
[1] parallel  stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] rwunderground_0.1.6 lubridate_1.6.0     rvest_0.3.2         xml2_1.1.1          pander_0.6.1       
 [6] knitr_1.17          cluster_2.0.6       factoextra_1.0.5    dtwclust_4.1.1      dtw_1.18-1         
[11] clue_0.3-54         proxy_0.4-17        zoo_1.8-0           odbc_1.1.3          DBI_0.7            
[16] dplyr_0.7.4         purrr_0.2.3         readr_1.1.1         tidyr_0.7.1         tibble_1.3.4       
[21] tidyverse_1.1.1     extrafont_0.17      bindrcpp_0.2        ggraph_1.0.0        ggplot2_2.2.1      
[26] igraph_1.1.2       

loaded via a namespace (and not attached):
 [1] nlme_3.1-131        bit64_0.9-7         httr_1.3.1          rprojroot_1.2       backports_1.1.1    
 [6] tools_3.4.2         R6_2.2.2            lazyeval_0.2.0      colorspace_1.3-2    tidyselect_0.2.0   
[11] gridExtra_2.3       mnormt_1.5-5        curl_3.0            bit_1.1-12          compiler_3.4.2     
[16] extrafontdb_1.0     flexclust_1.3-4     pkgmaker_0.22       labeling_0.3        scales_0.5.0       
[21] psych_1.7.8         stringr_1.2.0       digest_0.6.12       foreign_0.8-69      rmarkdown_1.6      
[26] pkgconfig_2.0.1     htmltools_0.3.6     highr_0.6           rlang_0.1.2         readxl_1.0.0       
[31] bindr_0.1           jsonlite_1.5        magrittr_1.5        modeltools_0.2-21   Matrix_1.2-11      
[36] Rcpp_0.12.13        munsell_0.4.3       viridis_0.4.0       stringi_1.1.5       yaml_2.1.14        
[41] MASS_7.3-47         plyr_1.8.4          grid_3.4.2          blob_1.1.0          ggrepel_0.7.0      
[46] bigmemory.sri_0.1.3 forcats_0.2.0       udunits2_0.13       lattice_0.20-35     haven_1.1.0        
[51] hms_0.3             ggpubr_0.1.5        rngtools_1.2.4      reshape2_1.4.2      codetools_0.2-15   
[56] stats4_3.4.2        XML_3.98-1.9        glue_1.1.1          evaluate_0.10.1     modelr_0.1.1       
[61] selectr_0.3-1       tweenr_0.1.5        foreach_1.4.3       Rttf2pt1_1.3.4      cellranger_1.1.0   
[66] gtable_0.2.0        assertthat_0.2.0    ggforce_0.1.1       xtable_1.8-2        broom_0.4.2        
[71] RSpectra_0.12-0     rsconnect_0.8.5     viridisLite_0.2.0   iterators_1.0.8     registry_0.3       
[76] units_0.4-6         bigmemory_4.5.19   
erichare commented 7 years ago

Hi Neil,

This occurred because this particular station was using precip_rate and precip_total for the every 5 minute observations - I just pushed a fix so that it should pull this data in now. With that said, the example you listed with precipm was the daily summary - the history function itself isnt using that value, its merely pulling the minute by minute updates. The daily summary can be derived from the minute by minute data however