R/plot_resp_rate.R

Defines functions plot_resp_rate

Documented in plot_resp_rate

#' Plot breating rate
#'
#' @param d data.frame, output from process_run_v2
#'
#' @return
#' @export
#'
#' @examples
plot_resp_rate <- function(d){
  require(ggplot2)
  require(glue)
  plt <- ggplot(filter(d, mins < max(mins,na.rm=T) - 2),
                aes(x = mins, y = respiration_rate)) +
    geom_line() +
    ylim(0,40) +
    labs(x = 'Minutes', y = 'Breathing rate') +
    theme_bw()
  plt <- plt + annotate('text',
                        x = max(d$mins, na.rm=T)-7,
                        y = 35,
                        label = glue("Average rate = {round(mean(d$respiration_rate, na.rm=T), 1)} / min"))
  print(plt)
}
Zansors/zdeviceR documentation built on Dec. 25, 2019, 12:23 a.m.