Skip to content

Commit a8337cf

Browse files
committed
More doc updates
1 parent dc147a3 commit a8337cf

2 files changed

Lines changed: 46 additions & 8 deletions

File tree

R/weather_stn.R

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
#' Prepare stations data for weather download
2+
#'
3+
#' Filters stations by station IDs and interval, converts start/end to dates.
4+
#'
5+
#' @param station_ids Character/Numeric vector. Station IDs to prepare
6+
#' @param interval Character. "hour", "day", or "month"
7+
#'
8+
#' @returns Tibble of prepared stations data with date ranges
9+
#'
10+
#' @noRd
11+
112
prep_stations <- function(station_ids, interval) {
213
stn <- stations_read() |>
314
dplyr::filter(
@@ -25,6 +36,21 @@ prep_stations <- function(station_ids, interval) {
2536
stn
2637
}
2738

39+
#' Prepare start and end dates for weather download
40+
#'
41+
#' Processes start and end dates for each station, handling NULL values,
42+
#' date limits, and detecting invalid date ranges.
43+
#'
44+
#' @param stn Data frame. Prepared stations data
45+
#' @param start Date. Requested start date for download or NULL for earliest
46+
#' available
47+
#' @param end Date. Requested end date for download or NULL for today
48+
#'
49+
#' @returns Tibble of stations data with start_use, end_use, and labels for
50+
#' later messages
51+
#'
52+
#' @noRd
53+
2854
prep_start_end <- function(stn, start, end) {
2955
# Check start/ends
3056
min_dt <- as.Date("1840-01-01") # Earliest date API will return
@@ -52,6 +78,18 @@ prep_start_end <- function(stn, start, end) {
5278
stn
5379
}
5480

81+
#' Prepare pagination for weather download
82+
#'
83+
#' Creates sequences of dates for paginated API requests based on interval
84+
#' (hourly by month, daily by year, monthly downloads full dataset).
85+
#'
86+
#' @param stn Data frame. Stations data with start_use and end_use dates
87+
#' @param months Numeric vector. Optional months to filter for hourly data
88+
#'
89+
#' @returns Tibble of stations data with pages column containing date sequences
90+
#'
91+
#' @noRd
92+
5593
prep_paging <- function(stn, months) {
5694
stn |>
5795
dplyr::mutate(

R/weathercan-package.R

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#' Easy downloading of weather data from Environment and Climate Change Canada
22
#'
3-
#' \code{weathercan} is an R package for simplifying the downloading of
3+
#' `weathercan` is an R package for simplifying the downloading of
44
#' Historical Climate Data from the Environment and Climate Change Canada (ECCC)
55
#' website (<https://climate.weather.gc.ca>)
66
#'
@@ -33,14 +33,14 @@
3333
#' - [`kamloops_day`]
3434
#' - [`pg`]
3535
#'
36-
#' As well as several vignettes available in the package and [Online](https://docs.ropensci.org/weathercan/):
36+
#' As well as several articles available [Online](https://docs.ropensci.org/weathercan/):
3737
#'
38-
#' - [General Usage](https://docs.ropensci.org/weathercan/articles/weathercan.html): `vignette("weathercan", package = "weathercan")`
39-
#' - [Interpolating](https://docs.ropensci.org/weathercan/articles/interpolate_data.html): `vignette("interpolation", package = "weathercan")`
40-
#' - [Reproducibility](https://docs.ropensci.org/weathercan/articles/reproducibility.html): `vignette("reproducibility", package = "weathercan")`
41-
#' - [Flags and Codes](https://docs.ropensci.org/weathercan/articles/flags.html): `vignette("flags", package = "weathercan")`
42-
#' - [Weather: Terms and Units](https://docs.ropensci.org/weathercan/articles/glossary.html): `vignette("glossary", package = "weathercan")`
43-
#' - [Climate Normals: Terms and Units](https://docs.ropensci.org/weathercan/articles/glossary_normals.html): `vignette("glossary_normals", package = "weathercan")`
38+
#' - [General Usage](https://docs.ropensci.org/weathercan/articles/weathercan.html)
39+
#' - [Interpolating](https://docs.ropensci.org/weathercan/articles/interpolate_data.html)
40+
#' - [Reproducibility](https://docs.ropensci.org/weathercan/articles/reproducibility.html)
41+
#' - [Flags and Codes](https://docs.ropensci.org/weathercan/articles/flags.html)
42+
#' - [Weather: Terms and Units](https://docs.ropensci.org/weathercan/articles/glossary.html)
43+
#' - [Climate Normals: Terms and Units](https://docs.ropensci.org/weathercan/articles/glossary_normals.html)
4444
#'
4545
#' We also have some advanced articles:
4646
#'

0 commit comments

Comments
 (0)