You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cran-comments.md
+22Lines changed: 22 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,25 @@
1
+
tidyhydat 0.5.6
2
+
=========================
3
+
4
+
There were zero WARNINGS and zero ERRORS.
5
+
6
+
There was one NOTE: 'Note: found 122 marked UTF-8 strings'. These strings are necessary for testing as the data source that this package accesses includes data with UTF-8 strings (french language accents)
7
+
8
+
## NEWS
9
+
- fixed CRAN document issue
10
+
- fixed bug created by HYDAT database name (#175)
11
+
12
+
## Test environments
13
+
* win-builder (via `devtools::check_win_devel()` and `devtools::check_win_release()`)
14
+
* local macOS, R 4.2.1 (via R CMD check --as-cran)
Another method is to use `hy_stations()` to generate your vector which is then given the `station_number` argument. For example, we could take a subset for only those active stations within Prince Edward Island (Province code:PE) and then create vector for `hy_daily_flows()`:
We can also merge our station choice and data extraction into one unified pipe which accomplishes a single goal. For example if for some reason we wanted all the stations in Canada that had the name "Canada" in them we unify that selection and data extraction process into a single pipe:
## Queried from version of HYDAT released on 2022-01-17
124
-
## Observations: 84,594
125
-
## Measurement flags: 25,617
126
+
## Queried from version of HYDAT released on 2022-07-21
127
+
## Observations: 86,056
128
+
## Measurement flags: 26,218
126
129
## Parameter(s): Flow
127
-
## Date range: 1918-08-01 to 2020-12-31
130
+
## Date range: 1918-08-01 to 2021-12-31
128
131
## Station(s) returned: 7
129
132
## Stations requested but not returned:
130
133
## All stations returned.
131
-
## # A tibble: 84,594 x 5
134
+
## # A tibble: 86,056 × 5
132
135
## STATION_NUMBER Date Parameter Value Symbol
133
136
## <chr> <date> <chr> <dbl> <chr>
134
137
## 1 01AK001 1918-08-01 Flow NA <NA>
@@ -141,7 +144,8 @@ search_stn_name("canada") %>%
141
144
## 8 01AK001 1918-08-08 Flow 1.78 <NA>
142
145
## 9 01AK001 1918-08-09 Flow 1.5 <NA>
143
146
## 10 01AK001 1918-08-10 Flow 1.78 <NA>
144
-
## # ... with 84,584 more rows
147
+
## # … with 86,046 more rows
148
+
## # ℹ Use `print(n = ...)` to see more rows
145
149
```
146
150
147
151
We saw above that if we were only interested in a subset of dates we could use the `start_date` and `end_date` arguments. A date must be supplied to both these arguments in the form of YYYY-MM-DD. If you were interested in all daily flow data from station number "08LA001" for 1981, you would specify all days in 1981 :
@@ -194,7 +198,7 @@ search_stn_name("liard")
194
198
```
195
199
196
200
```
197
-
## # A tibble: 9 x 5
201
+
## # A tibble: 9 × 5
198
202
## STATION_NUMBER STATION_NAME PROV_TERR_STATE_LOC LATITUDE LONGITUDE
199
203
## <chr> <chr> <chr> <dbl> <dbl>
200
204
## 1 10AA001 LIARD RIVER AT UPPER CROSSING YT 60.1 -129.
@@ -214,20 +218,21 @@ search_stn_number("08MF")
214
218
```
215
219
216
220
```
217
-
## # A tibble: 51 x 5
218
-
## STATION_NUMBER STATION_NAME PROV_TERR_STATE_LOC LATITUDE LONGITUDE
219
-
## <chr> <chr> <chr> <dbl> <dbl>
220
-
## 1 08MF005 FRASER RIVER AT HOPE BC 49.4 -121.
221
-
## 2 08MF035 FRASER RIVER NEAR AGASSIZ BC 49.2 -122.
222
-
## 3 08MF038 FRASER RIVER AT CANNOR BC 49.1 -122.
223
-
## 4 08MF040 FRASER RIVER ABOVE TEXAS CREEK BC 50.6 -122.
224
-
## 5 08MF062 COQUIHALLA RIVER BELOW NEEDLE CREEK BC 49.5 -121.
225
-
## 6 08MF065 NAHATLATCH RIVER BELOW TACHEWANA CREEK BC 50.0 -122.
226
-
## 7 08MF068 COQUIHALLA RIVER ABOVE ALEXANDER CREEK BC 49.4 -121.
227
-
## 8 08MF072 FRASER RIVER AT LAIDLAW BC 49.3 -122.
228
-
## 9 08MF073 FRASER RIVER AT HARRISON MILLS BC 49.2 -122.
229
-
## 10 08MF001 ANDERSON RIVER NEAR BOSTON BAR BC 49.8 -121.
Our objective here is to filter from this data for the station that has the longest record of flow (`DATA_TYPE == "Q"`). You'll also notice this symbol `%>%` which in R is called a [pipe](https://magrittr.tidyverse.org/reference/pipe.html). In code, read it as the word *then*. So for the data_range data we want to grab the data *then* filter it by flow ("Q") in `DATA_TYPE` and then by the maximum value of `RECORD_LENGTH`:
84
85
@@ -88,12 +89,12 @@ hy_stn_data_range() %>%
88
89
```
89
90
90
91
```
91
-
## Queried from version of HYDAT released on 2022-01-17
92
+
## Queried from version of HYDAT released on 2022-07-21
Working with SQL tables in dplyr is much like working with regular data frames, except no data is actually read from the database until necessary. Because some of these tables are large (particularly those containing the actual data), you will want to `filter()` the tables before you `collect()` them (the `collect()` operation loads them into memory as a `data.frame`).
@@ -78,7 +81,7 @@ Working with SQL tables in dplyr is much like working with regular data frames,
78
81
tbl(src, "STN_OPERATION_SCHEDULE") %>%
79
82
filter(STATION_NUMBER=="05AA008") %>%
80
83
collect()
81
-
#> # A tibble: 103 x 5
84
+
#> # A tibble: 103 × 5
82
85
#> STATION_NUMBER DATA_TYPE YEAR MONTH_FROM MONTH_TO
When you are finished with the database (i.e., the end of the script), it is good practice to close the connection (you may get a loud red warning if you don't!).
0 commit comments