6
6
# ' you need lots of data, consider using HYDAT and the `hy_` family of functions
7
7
# '
8
8
# ' @param station_number Water Survey of Canada station number.
9
- # ' @param start_date Accepts YYYY-MM-DD.
10
- # ' If only start date is supplied (i.e. YYYY-MM-DD) values are returned from the start of that day.
11
- # ' Defaults to 365 days before current date.
12
- # ' @param end_date Accepts either YYYY-MM-DD.
13
- # ' If only a date is supplied (i.e. YYYY-MM-DD) values are returned from the end of that day.
14
- # ' Defaults to current date.
9
+ # ' @param start_date Accepts YYYY-MM-DD. You need to provide a start date.
10
+ # ' The default value is NULL
11
+ # ' @param end_date Accepts either YYYY-MM-DD. You need to provide an end date.
12
+ # ' The default value is NULL
15
13
# '
16
14
# '
17
15
# ' @format A tibble with 6 variables:
26
24
# ' @seealso hy_daily_flows
27
25
# ' @examples
28
26
# ' \dontrun{
29
- # '
30
- # ' flow_data <- ws_daily_flows(
31
- # ' station_number = c("08NL071", "08NM174")
27
+ # ' try(
28
+ # ' flow_data <- ws_daily_flows(
29
+ # ' station_number = c("08NL071", "08NM174"),
30
+ # ' start_date = Sys.Date() - 365,
31
+ # ' end_date = Sys.Date()
32
+ # ' )
32
33
# ' )
33
- # '
34
- # ' level_data <- ws_daily_level(
35
- # ' station_number = c("08NL071", "08NM174")
34
+ # ' try(
35
+ # ' level_data <- ws_daily_level(
36
+ # ' station_number = c("08NL071", "08NM174"),
37
+ # ' start_date = Sys.Date() - 365,
38
+ # ' end_date = Sys.Date()
39
+ # ' )
36
40
# ' )
37
- # ' }
41
+ # '}
38
42
# ' @export
39
43
ws_daily_flows <- function (
40
44
station_number ,
41
- start_date = Sys.Date() - 365 ,
42
- end_date = Sys.Date() ) {
45
+ start_date = NULL ,
46
+ end_date = NULL ) {
43
47
44
48
get_historical_data(
45
49
station_number = station_number ,
@@ -53,8 +57,8 @@ ws_daily_flows <- function(
53
57
# ' @export
54
58
ws_daily_levels <- function (
55
59
station_number ,
56
- start_date = Sys.Date() - 365 ,
57
- end_date = Sys.Date() ) {
60
+ start_date = NULL ,
61
+ end_date = NULL ) {
58
62
59
63
get_historical_data(
60
64
station_number = station_number ,
@@ -72,6 +76,14 @@ get_historical_data <- function(
72
76
end_date ) {
73
77
parameters <- match.arg(parameters , choices = c(" level" , " flow" ))
74
78
79
+ if (is.null(start_date )) {
80
+ stop(" please provide a valid date for the start_date argument" , call. = FALSE )
81
+ }
82
+
83
+ if (is.null(end_date )) {
84
+ stop(" please provide a valid date for the end_date argument" , call. = FALSE )
85
+ }
86
+
75
87
# # Build link for GET
76
88
baseurl <- " https://wateroffice.ec.gc.ca/services/daily_data/csv/inline?"
77
89
0 commit comments