impute_time: Impute datetime for gaps in time series data

View source: R/impute_time.R

impute_timeR Documentation

Impute datetime for gaps in time series data

Description

impute_time() fills datetime gaps in time series data. Specifically, this function was designed to impute gaps in GPS data that may result from signal loss or because the GPS logger goes into 'sleep' mode (i.e. Columbus GPS logger). Datetime rows are added to the input data frame under the specified datetime column (dt_field) to fill gaps between time stamps. The sampling interval is automatically calculated.

Usage

impute_time(
  df,
  dt_field = NULL,
  fill_cols = NULL,
  force = FALSE,
  force_interval = 1
)

Arguments

df

a data frame with a datetime field.

dt_field

character; name of datetime field.

fill_cols

character; names of columns that should have values carried forward.

force

logical; force the function to fill time between sampling intervals even if no lapses are detected. For example, if location is recorded at a 5 second sampling interval, extra rows can be inserted to convert the sampling resolution to 1 measurement per second (⁠force = TRUE, force_interval = 1⁠). Default = FALSE.

force_interval

numeric; the new sampling frequency in seconds to be forced upon the input data frame. force_interval must be less than the sampling interval of the input data frame.

Details

Columns that have one unique value and are unaffected by imputation (i.e. participant or sample ID) can be specified under 'fill_cols. Values for these columns will be carried forward from the last observation. If NULL (default), only the datetime column (dt_field) will be assigned values for the imputed rows.

impute_coords() can be used in conjunction with impute_time() to assign latitude and longitude to the added timestamps/rows.

Examples

## Not run: 
impute_time(df, dt_field = 'Date_Time', fill_cols = 'ID') %>%
  impute_coords(dt_field = 'Date_Time')

## End(Not run)


wolfeclw/circleclust documentation built on Aug. 13, 2024, 3:33 a.m.