R/as_timeseries.R

Defines functions as_timeseries

Documented in as_timeseries

#' Convert an E4 data stream to a timeseries
#' @description Creates an xts object indexed by time
#' @param data A dataframe, subelements of list as output by read_e4 function
#' @param index Which column (integer) to use as the data in the timeseries. Default: 2.
#' @param name_col Column name to give to the timeseries data.
#'
#' @export
#' @importFrom xts xts
as_timeseries <- function(data, index = 2, name_col = "V1") {
  tdata <- pad_e4(data)

  panel <- xts(tdata[[index]], order.by = tdata[[1]])
  colnames(panel) <- name_col
  return(panel)
}
PCdLf/wearables documentation built on Nov. 19, 2024, 5:57 p.m.