R/mergeFitbitData.R

Defines functions mergeFitbitData

Documented in mergeFitbitData

mergeFitbitData = function(filenames = NULL, desiredtz = "", configtz = NULL) {
  if (length(filenames) < 2) {
    stop("Provide at least two filenames")
  }
  cnt = 1
  while (cnt <= length(filenames)) {
    D = readFitbit(filename = filenames[cnt], desiredtz = desiredtz, configtz = configtz)
    if (cnt == 1) {
      data = D
    } else {
      if (length(intersect(x = data$dateTime, D$dateTime)) == 0) {
        warning(paste0("Time series do not intersect for files ",
                       basename(filenames[cnt]), " and ", basename(filenames[cnt - 1])),
                call. = FALSE)
      }
      
      data = merge(data, D, by = "dateTime", all = TRUE)
    }
    cnt = cnt + 1
  }
  return(data)
}

Try the GGIRread package in your browser

Any scripts or data that you put into this service are public.

GGIRread documentation built on Oct. 25, 2024, 5:06 p.m.