Skip to contents

Construct a function that takes a data frame and returns another data frame with a time variable converted so that it has the correct format, class, and/or type.

Usage

TimeVariableConverter(
  as_date = as.Date,
  as_integer = as.integer,
  as_numeric = as.numeric
)

Arguments

as_date

Function that takes a vector and converts it to a date vector if possible. Used only if time_variable is in std_date_variables().

as_integer

Function that takes a vector and converts it to an integer vector if possible. Used only if time_variable is in std_integer_variables().

as_numeric

Function that takes a vector and converts it to a numeric vector if possible. Used only if time_variable is in std_numeric_variables().

Returned Function

  • Arguments :

    • data : Data frame containing a time variable.

    • time_variable : Column name of time variable in data. The default is "period_end_date".

  • Return : A version of data with time_variable column converted to