R/physio-match_marker_eda.R

Defines functions match_marker_eda.physio

Documented in match_marker_eda.physio

#' match_marker_eda.physio()
#'
#' Matches marker object and compressed physio EDA data. Output can be plotted or used for further summary calculations.
#'
#' @param data; a dataframe generated by compress_eda.physio()
#' @param marker; a dataframe generate by marker()
#' @return dataframe
#' @export

match_marker_eda.physio <- function(data, marker){
  marker[1,1] <- marker[1,1] + 1
  i = 1
  for (sec in round(marker[,1])){
    data[sec,3] <- marker$EVENT[i]
    i <- i + 1
  }
  names(data)[3] <- "EVENT"
  event <- data$EVENT[1]
  #fill NA values
  for (n in 1:nrow(data)){
    if (is.na(data$EVENT[n])){
      data$EVENT[n] <- event
      }
    else {
      event <- data$EVENT[n]
    }
  }
  return(data)
}
Fiddleman/NeuroIS documentation built on Nov. 1, 2017, 7:03 a.m.