Skip to contents

Get range

Usage

get_range(plot_range, full_range)

Arguments

plot_range

the time frame to use for the plot. Use "Past year" (default) to see the last year of data, or "Calendar year" to use the current calendar year, beginning in January. Or specify two dates representing the start and end of the plot.

full_range

the full time range of the data.

Value

list of plot_start, plot_end, label

Examples

full_range <- c("2000-01-01", "2025-10-01")
get_range("Past year", full_range)
#> $plot_start
#> [1] "2025-01-01"
#> 
#> $plot_end
#> [1] "2026-01-01"
#> 
#> $x_label
#> [1] "2025 - 2026"
#> 
get_range("Calendar year", full_range)
#> $plot_start
#> [1] "2025-01-01"
#> 
#> $plot_end
#> [1] "2025-12-31"
#> 
#> $x_label
#> [1] "2025"
#> 
get_range(c("2024-10-01", "2025-06-01"), full_range)
#> $plot_start
#> [1] "2024-10-01"
#> 
#> $plot_end
#> [1] "2025-06-01"
#> 
#> $x_label
#> [1] "2024 - 2025"
#> 
get_range(c(NA, "2020-01-01"), full_range)
#> $plot_start
#> [1] "2000-01-01"
#> 
#> $plot_end
#> [1] "2020-01-01"
#> 
#> $x_label
#> [1] "2000 - 2020"
#> 
get_range(c("2020-01-01", NA), full_range)
#> $plot_start
#> [1] "2020-01-01"
#> 
#> $plot_end
#> [1] "2025-10-01"
#> 
#> $x_label
#> [1] "2020 - 2025"
#>