Add a time variable with integer values for evenly sampled data

make_integer_times(data, period = NULL, tol = 1e-06)

Arguments

data

dataset to modify

period

period to check the times against (if NULL, first check to see if there is a known period set in the metadata, otherwise assumes 1)

tol

tolerance for the period

Value

the dataset, with integer times

Details

First, check if the data are evenly sampled in time. If not, we exit early. Next, if the times are already integer or Date, we don't do anything. If the times are numeric, but roundable to integer, we round. Otherwise, we add a new variable to covariates from 1:n and designate this variable as the timename.