Skip to content

Commit 89f56a9

Browse files
committed
cleanup
1 parent c9dd193 commit 89f56a9

1 file changed

Lines changed: 13 additions & 15 deletions

File tree

vignettes/daily_data_statistics.Rmd

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ editor_options:
1212
```{r, include = FALSE}
1313
knitr::opts_chunk$set(
1414
collapse = TRUE,
15-
comment = "#>"
15+
comment = "#>",
16+
message = FALSE,
17+
warning = FALSE
1618
)
1719
1820
library(dataRetrieval)
@@ -40,7 +42,7 @@ Day-of-year and month-of-year statistics aggregate observations for the same cal
4042
Consider the output below, where we request day-of-year discharge averages for January 1 and January 2.
4143
Note that the `start_date` and `end_date` are set in `month-year` format to describe the day-of-year range.
4244

43-
```{r, message=FALSE, warning=FALSE}
45+
```{r}
4446
jan_por_mean <-
4547
read_waterdata_stats_por(
4648
monitoring_location_id = site1,
@@ -67,10 +69,10 @@ Let's now look at an example that illustrates the benefits of the statistics API
6769
In the example below, we pull all day-of-year discharge percentiles for our site.
6870
Keep in mind that doing so *without* the statistics API would require us to download the **entire** daily period of record for this site and hand-compute these percentiles ourselves, a time- and resource-intensive process indeed.
6971

70-
For demonstration, we filter the output to the January 1 day-of-year percentiles, which include a set of percentiles commonly used on WDFN webpages (e.g., [Wisconsin water conditions](https://waterdata.usgs.gov/state/wisconsin/)).
72+
For demonstration, we filter the output to the January 1 day-of-year percentiles, which include a set of percentiles commonly used on the Water Data for the Nation (WDFN) webpages (e.g., [Wisconsin water conditions](https://waterdata.usgs.gov/state/wisconsin/)).
7173

7274

73-
```{r, message=FALSE, warning=FALSE}
75+
```{r}
7476
full_por_percentiles <-
7577
read_waterdata_stats_por(
7678
monitoring_location_id = site1,
@@ -91,7 +93,7 @@ full_por_percentiles |>
9193
After a bit of data manipulation, we can then visualize the percentiles as "ribbons" on a plot.
9294
Each ribbon spans between two percentiles returned by the /statistics API (e.g., minimum to 5th, 5th to 10th, etc).
9395

94-
```{r, message=FALSE, warning=FALSE}
96+
```{r}
9597
doy_perc_bands <-
9698
full_por_percentiles |>
9799
sf::st_drop_geometry() |>
@@ -150,7 +152,7 @@ ggplot(data = doy_perc_bands,
150152

151153
Finally, let's overlay daily mean data onto the plot:
152154

153-
```{r, message=FALSE, warning=FALSE}
155+
```{r}
154156
range <- as.Date(c("2025-01-01", "2026-03-02"))
155157
156158
complete_df <- data.frame(time = seq.Date(from = range[1],
@@ -216,7 +218,7 @@ ggplot(data = daily_data,
216218
217219
```
218220

219-
As <https://waterdata.usgs.gov/monitoring-location/USGS-02037500/statistical-graphs/>
221+
As also seen on the WDFN pages: <https://waterdata.usgs.gov/monitoring-location/USGS-02037500/statistical-graphs/>
220222

221223

222224
## Fetching monthly and annual statistics within a date range
@@ -225,7 +227,7 @@ Unlike day- or month-of-year statistics, which summarize typical seasonal condit
225227
Consider the example below where we fetch the average discharge value for the month of January, 2024.
226228
Notice that the `start_date` and `end_date` arguments are given in `YYYY-MM-DD` format.
227229

228-
```{r, message=FALSE, warning=FALSE}
230+
```{r}
229231
jan_daterange_mean <-
230232
read_waterdata_stats_daterange(
231233
monitoring_location_id = site1,
@@ -238,15 +240,11 @@ jan_daterange_mean <-
238240
jan_daterange_mean
239241
```
240242

241-
Instead of `time_of_year` and `time_of_year_type` columns, this output contains `start_date`, `end_date`, and `interval_type` columns representing the daterange over which the average was calculated.
242-
The first row shows the average January, 2024 discharge was about 112 cubic feet per second.
243-
We again have extra rows: the second row contains the **calendar** year 2024 average and the third contains the **water** year 2024 average.
243+
Instead of `time_of_year` and `time_of_year_type` columns, this output contains `start_date`, `end_date`, and `interval_type` columns representing the daterange over which the average was calculated. The first row shows the average January, 2024 discharge was about 112 cubic feet per second. We again have extra rows: the second row contains the **calendar** year 2024 average and the third contains the **water** year 2024 average.
244244

245-
Annual statistics will be returned for any calendar/water years than intersect with the specified date range.
246-
Consider the example below, where the `start_date` to `end_date` range is only 93 days yet happens to intersect with calendar **and** water years 2023 and 2024.
247-
We see this reflected in output containing monthly averages for September, 2023 through January, 2024 as well as 2023 and 2024 calendar and water year averages.
245+
Annual statistics will be returned for any calendar/water years than intersect with the specified date range. Consider the example below, where the `start_date` to `end_date` range is only 93 days yet happens to intersect with calendar **and** water years 2023 and 2024. We see this reflected in output containing monthly averages for September, 2023 through January, 2024 as well as 2023 and 2024 calendar and water year averages.
248246

249-
```{r, message=FALSE, warning=FALSE}
247+
```{r}
250248
multiyear_daterange_mean <-
251249
read_waterdata_stats_daterange(
252250
monitoring_location_id = site1,

0 commit comments

Comments
 (0)