sample.data.environment.EMA = sample.data.environment %>%
dplyr::filter(Id == "Participant") %>%
filter_Datetime(length = lubridate::days(2)) %>%
dplyr::mutate(MEDI.EMA = exponential_moving_average(MEDI, Datetime))
# Plot to compare results
sample.data.environment.EMA %>%
ggplot2::ggplot(ggplot2::aes(x = Datetime)) +
ggplot2::geom_line(ggplot2::aes(y = MEDI), colour = "black") +
ggplot2::geom_line(ggplot2::aes(y = MEDI.EMA), colour = "red")
Run the code above in your browser using DataLab