get_index_limits: Convenient Function to get the index limits of a 'data.frame'...

View source: R/get_index_limits.R

get_index_limitsR Documentation

Convenient Function to get the index limits of a data.frame or data.table

Description

Convenient function to get the index limits of a data.table with a variable called index. This function is especially useful to extend the axis limits of a 'ggplot' using the min.extend and max.extend arguments of this function.

Usage

get_index_limits(.data, min.extend = 0, max.extend = 0)

Arguments

.data

a data.table with a variable index

min.extend

how much to extend the limits relative to the minimum

max.extend

how much to extend the limits relative to the maximum

Value

a numeric vector of length 2, where the first element is the minimum and the second element is the maximum

Examples

DT <- data.table(index = as.Date(c("2010-01-01", "2015-01-01", "2021-01-01")))
get_index_limits(DT)
get_index_limits(DT, max.extend = 365)
get_index_limits(DT, min.extend = 365)
get_index_limits(DT, min.extend = -365)

ChandlerLutz/CLmisc documentation built on Dec. 2, 2022, 12:40 p.m.