ropensci / tidyhydat

An R package to import Water Survey of Canada hydrometric data and make it tidy
https://docs.ropensci.org/tidyhydat
Apache License 2.0
70 stars 19 forks source link

carry ellipsis forward in print method #200

Closed vincenzocoia closed 1 year ago

vincenzocoia commented 1 year ago

Carry ellipsis forward to allow other args to be specified in print method.

Motivating Example

For example, as it is, cannot print more lines than the default, 10:

library(tidyhydat)
library(tibble)
flows <- hy_annual_stats("01AA002")
print(flows)
#>   Queried from version of HYDAT released on 2023-07-19
#>    Observations:                      24
#>    Measurement flags:                 8
#>    Parameter(s):                      Flow
#>    Date range:                        1969-03-06 to 1976-04-03 
#>    Station(s) returned:               1
#>    Stations requested but not returned: 
#>     All stations returned.
#> # A tibble: 24 × 7
#>    STATION_NUMBER Parameter  Year Sum_stat   Value Date       Symbol        
#>    <chr>          <chr>     <int> <chr>      <dbl> <date>     <chr>         
#>  1 01AA002        Flow       1969 MEAN      18     NA         <NA>          
#>  2 01AA002        Flow       1969 MIN        1.98  1969-03-06 Ice Conditions
#>  3 01AA002        Flow       1969 MAX      161     1969-04-18 <NA>          
#>  4 01AA002        Flow       1970 MEAN      15.9   NA         <NA>          
#>  5 01AA002        Flow       1970 MIN        0.670 1970-08-17 <NA>          
#>  6 01AA002        Flow       1970 MAX      280     1970-04-26 Ice Conditions
#>  7 01AA002        Flow       1971 MEAN      14.2   NA         <NA>          
#>  8 01AA002        Flow       1971 MIN        1.25  1971-02-05 Ice Conditions
#>  9 01AA002        Flow       1971 MAX      213     1971-08-29 <NA>          
#> 10 01AA002        Flow       1972 MEAN      16.6   NA         <NA>          
#> # ℹ 14 more rows

Same output, even if n = Inf:

print(flows, n = Inf)
#>   Queried from version of HYDAT released on 2023-07-19
#>    Observations:                      24
#>    Measurement flags:                 8
#>    Parameter(s):                      Flow
#>    Date range:                        1969-03-06 to 1976-04-03 
#>    Station(s) returned:               1
#>    Stations requested but not returned: 
#>     All stations returned.
#> # A tibble: 24 × 7
#>    STATION_NUMBER Parameter  Year Sum_stat   Value Date       Symbol        
#>    <chr>          <chr>     <int> <chr>      <dbl> <date>     <chr>         
#>  1 01AA002        Flow       1969 MEAN      18     NA         <NA>          
#>  2 01AA002        Flow       1969 MIN        1.98  1969-03-06 Ice Conditions
#>  3 01AA002        Flow       1969 MAX      161     1969-04-18 <NA>          
#>  4 01AA002        Flow       1970 MEAN      15.9   NA         <NA>          
#>  5 01AA002        Flow       1970 MIN        0.670 1970-08-17 <NA>          
#>  6 01AA002        Flow       1970 MAX      280     1970-04-26 Ice Conditions
#>  7 01AA002        Flow       1971 MEAN      14.2   NA         <NA>          
#>  8 01AA002        Flow       1971 MIN        1.25  1971-02-05 Ice Conditions
#>  9 01AA002        Flow       1971 MAX      213     1971-08-29 <NA>          
#> 10 01AA002        Flow       1972 MEAN      16.6   NA         <NA>          
#> # ℹ 14 more rows

Desired output below the summary message:

print(as_tibble(flows), n = Inf)
#> # A tibble: 24 × 7
#>    STATION_NUMBER Parameter  Year Sum_stat   Value Date       Symbol        
#>    <chr>          <chr>     <int> <chr>      <dbl> <date>     <chr>         
#>  1 01AA002        Flow       1969 MEAN      18     NA         <NA>          
#>  2 01AA002        Flow       1969 MIN        1.98  1969-03-06 Ice Conditions
#>  3 01AA002        Flow       1969 MAX      161     1969-04-18 <NA>          
#>  4 01AA002        Flow       1970 MEAN      15.9   NA         <NA>          
#>  5 01AA002        Flow       1970 MIN        0.670 1970-08-17 <NA>          
#>  6 01AA002        Flow       1970 MAX      280     1970-04-26 Ice Conditions
#>  7 01AA002        Flow       1971 MEAN      14.2   NA         <NA>          
#>  8 01AA002        Flow       1971 MIN        1.25  1971-02-05 Ice Conditions
#>  9 01AA002        Flow       1971 MAX      213     1971-08-29 <NA>          
#> 10 01AA002        Flow       1972 MEAN      16.6   NA         <NA>          
#> 11 01AA002        Flow       1972 MIN        1.42  1972-03-10 Ice Conditions
#> 12 01AA002        Flow       1972 MAX      168     1972-05-15 <NA>          
#> 13 01AA002        Flow       1973 MEAN      21.2   NA         <NA>          
#> 14 01AA002        Flow       1973 MIN        0.730 1973-07-27 <NA>          
#> 15 01AA002        Flow       1973 MAX      198     1973-04-23 Ice Conditions
#> 16 01AA002        Flow       1974 MEAN      17.8   NA         <NA>          
#> 17 01AA002        Flow       1974 MIN        0.310 1974-08-17 Estimated     
#> 18 01AA002        Flow       1974 MAX      255     1974-05-01 <NA>          
#> 19 01AA002        Flow       1975 MEAN      13.4   NA         <NA>          
#> 20 01AA002        Flow       1975 MIN        0.540 1975-08-11 <NA>          
#> 21 01AA002        Flow       1975 MAX      128     1975-05-05 <NA>          
#> 22 01AA002        Flow       1976 MEAN      25.5   NA         <NA>          
#> 23 01AA002        Flow       1976 MIN        1.25  1976-01-25 Ice Conditions
#> 24 01AA002        Flow       1976 MAX      281     1976-04-03 Ice Conditions

Created on 2023-08-16 with reprex v2.0.2

boshek commented 1 year ago

Ah nice. Yeah this looks good. Really this probably also should be added here as well. Are you able to do that quick?

https://github.com/ropensci/tidyhydat/blob/c952401c568eb72045159188032d470fe3c49c18/R/realtime-classes.R#L32

vincenzocoia commented 1 year ago

Are you able to do that quick?

Sorry, missed that. Thanks for getting to it!

boshek commented 1 year ago

Are you able to do that quick?

Sorry, missed that. Thanks for getting to it!

@vincenzocoia no immediate plans to do a CRAN release so hopefully this github version will work for you for a while.