Skip to contents

Get and Set Time Conversion Factors

Usage

set_time_conversion(
  default = "days",
  days = 1,
  weeks = 7,
  months = 365.25/12,
  years = 365.25
)

get_time_conversion(factor = c("days", "weeks", "months", "years"))

Arguments

default

The default time scale, commonly whichever has factor = 1

days

Factor to divide data time units to get time in days

weeks

Factor to divide data time units to get time in weeks

months

Factor to divide data time units to get time in months

years

Factor to divide data time units to get time in years

factor

Time factor to get.

Value

No value returned. Conversion factors are stored internally and used within functions.

Examples

# The default time scale is days:
set_time_conversion(default = "days", days = 1, weeks = 7, months = 365.25 / 12, years = 365.25)

# Set the default time scale to years
set_time_conversion(
  default = "years",
  days = 1 / 365.25,
  weeks = 1 / 52.17857,
  months = 1 / 12,
  years = 1
)

# Get time scale factors:
get_time_conversion("years")
#> years 
#>     1 
get_time_conversion("weeks")
#>      weeks 
#> 0.01916496