ropensci / GSODR

API Client for Global Surface Summary of the Day (GSOD) Weather Data Client in R
https://docs.ropensci.org/GSODR
Other
90 stars 15 forks source link

Downloading data #121

Closed femiguez closed 2 months ago

femiguez commented 3 months ago
Session Info I just updated GSODR from CRAN (4.1.1) and I get this error when running the example ```r tbar <- get_GSOD(years = 2010, station = "955510-99999") ## Error in fifelse(STP_ATTRIBUTES == " 0", NA, STP) : ## 'yes' is of type logical but 'no' is of type character. Please make sure that both arguments have the same type. ``` It is possible that it is because I'm running R 4.3.0. The only other package I have loaded is apsimx.
adamhsparks commented 3 months ago

Hmmm. Thanks. That’s {data.table} most likely. I’ll look into it

adamhsparks commented 3 months ago

@femiguez, what version of {data.table} is installed? I don't get any errors when I run tests locally with R4.3.0. Perhaps I need to add a version to the Imports for {data.table}.

[ FAIL 0 | WARN 0 | SKIP 0 | PASS 101 ]

🧿 Your tests look perfect 🧿
> sessioninfo::session_info()
─ Session info ────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.3.0 (2023-04-21)
 os       macOS 14.6
 system   aarch64, darwin20
 ui       X11
 language (EN)
 collate  en_AU.UTF-8
 ctype    en_AU.UTF-8
 tz       Australia/Perth
 date     2024-08-01
 pandoc   3.2.1 @ /opt/homebrew/bin//pandoc

─ Packages ────────────────────────────────────────────────────────────────────────────────────────────────────
 ! package     * version date (UTC) lib source
   askpass       1.2.0   2023-09-03 [1] CRAN (R 4.3.0)
   brio          1.1.5   2024-04-24 [1] CRAN (R 4.3.1)
   cachem        1.1.0   2024-05-16 [1] CRAN (R 4.3.3)
   callr         3.7.6   2024-03-25 [1] CRAN (R 4.3.1)
   cli           3.6.3   2024-06-21 [1] CRAN (R 4.3.3)
   credentials   2.0.1   2023-09-06 [1] CRAN (R 4.3.0)
   curl          5.2.1   2024-03-01 [1] CRAN (R 4.3.1)
   data.table    1.15.4  2024-03-30 [1] CRAN (R 4.3.1)
   desc          1.4.3   2023-12-10 [1] CRAN (R 4.3.1)
   devtools      2.4.5   2022-10-11 [1] CRAN (R 4.3.0)
   digest        0.6.36  2024-06-23 [1] CRAN (R 4.3.3)
   ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.3.0)
   fansi         1.0.6   2023-12-08 [1] CRAN (R 4.3.1)
   fastmap       1.2.0   2024-05-15 [1] CRAN (R 4.3.3)
   fs            1.6.4   2024-04-25 [1] CRAN (R 4.3.1)
   glue          1.7.0   2024-01-09 [1] CRAN (R 4.3.1)
 R GSODR       * 4.1.1   <NA>       [?] <NA>
   htmltools     0.5.8.1 2024-04-04 [1] CRAN (R 4.3.1)
   htmlwidgets   1.6.4   2023-12-06 [1] CRAN (R 4.3.1)
   httpuv        1.6.15  2024-03-26 [1] CRAN (R 4.3.1)
   jsonlite      1.8.8   2023-12-04 [1] CRAN (R 4.3.1)
   later         1.3.2   2023-12-06 [1] CRAN (R 4.3.1)
   lifecycle     1.0.4   2023-11-07 [1] CRAN (R 4.3.1)
   magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.3.0)
   memoise       2.0.1   2021-11-26 [1] CRAN (R 4.3.0)
   mime          0.12    2021-09-28 [1] CRAN (R 4.3.0)
   miniUI        0.1.1.1 2018-05-18 [1] CRAN (R 4.3.0)
   openssl       2.2.0   2024-05-16 [1] CRAN (R 4.3.3)
   pak           0.7.2   2024-03-27 [1] local
   pillar        1.9.0   2023-03-22 [1] CRAN (R 4.3.0)
   pkgbuild      1.4.4   2024-03-17 [1] CRAN (R 4.3.1)
   pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.3.0)
   pkgload       1.4.0   2024-06-28 [1] CRAN (R 4.3.3)
   praise        1.0.0   2015-08-11 [1] CRAN (R 4.3.0)
   processx      3.8.4   2024-03-16 [1] CRAN (R 4.3.1)
   profvis       0.3.8   2023-05-02 [1] CRAN (R 4.3.0)
   promises      1.3.0   2024-04-05 [1] CRAN (R 4.3.1)
   ps            1.7.7   2024-07-02 [1] CRAN (R 4.3.3)
   purrr         1.0.2   2023-08-10 [1] CRAN (R 4.3.0)
   R6            2.5.1   2021-08-19 [1] CRAN (R 4.3.0)
   Rcpp          1.0.13  2024-07-17 [1] CRAN (R 4.3.3)
   remotes       2.5.0   2024-03-17 [1] CRAN (R 4.3.1)
   rlang         1.1.4   2024-06-04 [1] CRAN (R 4.3.3)
   rprojroot     2.0.4   2023-11-05 [1] CRAN (R 4.3.1)
   rstudioapi    0.16.0  2024-03-24 [1] CRAN (R 4.3.1)
   sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.3.0)
   shiny         1.9.0   2024-07-29 [1] CRAN (R 4.3.3)
   stringi       1.8.4   2024-05-06 [1] CRAN (R 4.3.1)
   stringr       1.5.1   2023-11-14 [1] CRAN (R 4.3.1)
   sys           3.4.2   2023-05-23 [1] CRAN (R 4.3.0)
   testthat    * 3.2.1.1 2024-04-14 [1] CRAN (R 4.3.1)
   tibble        3.2.1   2023-03-20 [1] CRAN (R 4.3.0)
   urlchecker    1.0.1   2021-11-30 [1] CRAN (R 4.3.0)
   usethis       3.0.0   2024-07-29 [1] CRAN (R 4.3.3)
   utf8          1.2.4   2023-10-22 [1] CRAN (R 4.3.1)
   vctrs         0.6.5   2023-12-01 [1] CRAN (R 4.3.1)
   withr         3.0.1   2024-07-31 [1] CRAN (R 4.3.3)
   xtable        1.8-4   2019-04-21 [1] CRAN (R 4.3.0)

 [1] /Users/adamsparks/Library/R/arm64/4.3/library
 [2] /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library

 R ── Package was removed from disk.

───────────────────────────────────────────────────────────────────────────────────────────────────────────────
adamhsparks commented 3 months ago

With your example in R4.3.0 it seems to work for me, locally. This is a completely fresh install, so {data.table} is the latest version as is everything else but the R version.

> library("GSODR")
Warning message:
package 'GSODR' was built under R version 4.3.3 
> tbar <- get_GSOD(years = 2021, station = "955510-99999")
> tbar
            STNID              NAME   CTRY COUNTRY_NAME  ISO2C  ISO3C  STATE LATITUDE LONGITUDE ELEVATION
           <char>            <char> <char>       <char> <char> <char> <char>    <num>     <num>     <num>
  1: 955510-99999 TOOWOOMBA AIRPORT     AS    AUSTRALIA     AU    AUS          -27.55   151.917       642
  2: 955510-99999 TOOWOOMBA AIRPORT     AS    AUSTRALIA     AU    AUS          -27.55   151.917       642
  3: 955510-99999 TOOWOOMBA AIRPORT     AS    AUSTRALIA     AU    AUS          -27.55   151.917       642
  4: 955510-99999 TOOWOOMBA AIRPORT     AS    AUSTRALIA     AU    AUS          -27.55   151.917       642
  5: 955510-99999 TOOWOOMBA AIRPORT     AS    AUSTRALIA     AU    AUS          -27.55   151.917       642
 ---                                                                                                     
358: 955510-99999 TOOWOOMBA AIRPORT     AS    AUSTRALIA     AU    AUS          -27.55   151.917       642
359: 955510-99999 TOOWOOMBA AIRPORT     AS    AUSTRALIA     AU    AUS          -27.55   151.917       642
360: 955510-99999 TOOWOOMBA AIRPORT     AS    AUSTRALIA     AU    AUS          -27.55   151.917       642
361: 955510-99999 TOOWOOMBA AIRPORT     AS    AUSTRALIA     AU    AUS          -27.55   151.917       642
362: 955510-99999 TOOWOOMBA AIRPORT     AS    AUSTRALIA     AU    AUS          -27.55   151.917       642
        BEGIN      END   YEARMODA  YEAR MONTH   DAY  YDAY  TEMP TEMP_ATTRIBUTES  DEWP DEWP_ATTRIBUTES    SLP
        <int>    <int>     <Date> <int> <int> <int> <int> <num>           <int> <num>           <int>  <num>
  1: 19980301 20240718 2021-01-01  2021     1     1     1  20.9              16  18.1              15 1011.5
  2: 19980301 20240718 2021-01-02  2021     1     2     2  21.2              16  17.8              16 1009.1
  3: 19980301 20240718 2021-01-03  2021     1     3     3  21.0              16  19.2              16 1008.3
  4: 19980301 20240718 2021-01-04  2021     1     4     4  22.2              16  19.4              15 1008.6
  5: 19980301 20240718 2021-01-05  2021     1     5     5  23.6              16  19.8              16 1009.3
 ---                                                                                                        
358: 19980301 20240718 2021-12-27  2021    12    27   361  20.5              24  16.2              24 1009.3
359: 19980301 20240718 2021-12-28  2021    12    28   362  16.7              24  13.1              24 1012.0
360: 19980301 20240718 2021-12-29  2021    12    29   363  18.1              24  13.7              24 1012.4
361: 19980301 20240718 2021-12-30  2021    12    30   364  18.4              24  13.5              24 1012.6
362: 19980301 20240718 2021-12-31  2021    12    31   365  18.4              24  17.0              21 1010.9
     SLP_ATTRIBUTES   STP STP_ATTRIBUTES VISIB VISIB_ATTRIBUTES  WDSP WDSP_ATTRIBUTES MXSPD  GUST   MAX
              <int> <num>          <int> <num>            <int> <num>           <int> <num> <num> <num>
  1:             16 940.5             16    NA                0   8.0              16   9.8    NA  25.6
  2:             16 938.2             16    NA                0   6.2              16   9.3    NA  25.7
  3:             16 937.4             16    NA                0   4.9              16   8.2    NA  25.5
  4:             16 937.7             16    NA                0   3.9              16   5.7    NA  25.0
  5:             16 938.4             16    NA                0   3.4              16   7.7    NA  28.1
 ---                                                                                                   
358:             24 938.1             24    NA                0   7.0              24   9.8    NA  27.2
359:             24 940.7             24    NA                0   8.2              24  10.8    NA  20.2
360:             24 941.0             24    NA                0   8.7              24  10.8    NA  24.0
361:             24 941.2             24    NA                0   8.4              24  11.8    NA  24.5
362:             24 939.7             24    NA                0   9.2              24  12.3    NA  22.2
     MAX_ATTRIBUTES   MIN MIN_ATTRIBUTES  PRCP PRCP_ATTRIBUTES  SNDP I_FOG I_RAIN_DRIZZLE I_SNOW_ICE I_HAIL
             <char> <num>         <char> <num>          <char> <num> <num>          <num>      <num>  <num>
  1:              *  16.7           <NA>  2.03               G    NA     1              1          0      0
  2:              *  17.6           <NA>  0.25               G    NA     0              0          0      0
  3:              *  17.7           <NA> 19.05               G    NA     1              1          0      0
  4:              *  18.8           <NA>  0.25               G    NA     0              0          0      0
  5:              *  19.0           <NA>  0.51               G    NA     0              0          0      0
 ---                                                                                                       
358:              *  17.0              *  0.00               I    NA     0              0          0      0
359:              *  13.5              *  0.00               I    NA     0              0          0      0
360:              *  13.4           <NA>  0.00               I    NA     0              0          0      0
361:              *  13.9           <NA>  0.25               G    NA     0              1          0      0
362:              *  14.8           <NA>  7.11               G    NA     0              1          0      0
     I_THUNDER I_TORNADO_FUNNEL    EA    ES    RH
         <num>            <num> <num> <num> <num>
  1:         0                0   2.1   2.5  84.0
  2:         0                0   2.0   2.5  81.0
  3:         0                0   2.2   2.5  89.5
  4:         0                0   2.2   2.7  84.2
  5:         0                0   2.3   2.9  79.3
 ---                                             
358:         0                0   1.8   2.4  76.4
359:         0                0   1.5   1.9  79.3
360:         0                0   1.6   2.1  75.5
361:         0                0   1.5   2.1  73.1
362:         0                0   1.9   2.1  91.6
> sessioninfo::session_info()
─ Session info ────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.3.0 (2023-04-21)
 os       macOS 14.6
 system   aarch64, darwin20
 ui       X11
 language (EN)
 collate  en_AU.UTF-8
 ctype    en_AU.UTF-8
 tz       Australia/Perth
 date     2024-08-01
 pandoc   3.2.1 @ /opt/homebrew/bin//pandoc

─ Packages ────────────────────────────────────────────────────────────────────────────────────────────────────
 package     * version date (UTC) lib source
 askpass       1.2.0   2023-09-03 [1] CRAN (R 4.3.0)
 bit           4.0.5   2022-11-15 [1] CRAN (R 4.3.0)
 bit64         4.0.5   2020-08-30 [1] CRAN (R 4.3.0)
 cli           3.6.3   2024-06-21 [1] CRAN (R 4.3.3)
 credentials   2.0.1   2023-09-06 [1] CRAN (R 4.3.0)
 curl          5.2.1   2024-03-01 [1] CRAN (R 4.3.1)
 data.table    1.15.4  2024-03-30 [1] CRAN (R 4.3.1)
 GSODR       * 4.1.1   2024-07-23 [1] CRAN (R 4.3.3)
 jsonlite      1.8.8   2023-12-04 [1] CRAN (R 4.3.1)
 openssl       2.2.0   2024-05-16 [1] CRAN (R 4.3.3)
 pak           0.7.2   2024-03-27 [1] local
 rlang         1.1.4   2024-06-04 [1] CRAN (R 4.3.3)
 sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.3.0)
 sys           3.4.2   2023-05-23 [1] CRAN (R 4.3.0)

 [1] /Users/adamsparks/Library/R/arm64/4.3/library
 [2] /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library

───────────────────────────────────────────────────────────────────────────────────────────────────────────────
femiguez commented 3 months ago

@adamhsparks Thanks for looking at this. I'll update 'data.table' and report back. Updating 'data.table' solved the reported issue but I'm having another one. It's late here, so I'll look at this tomorrow. Thanks! :)