#' @title add_clre_limits
#' @description Function to add alert limits to a dataframe.
#'
#' @param df Dataframe that contains technology and call_subject columns.
#'
#' @return Returns dataframe with alert limits joined.
#' @export
add_clre_limits <- function(df) {
limits <- qrc_link(query = 'select * from clre_limits;')
defaults <- qrc_link(query = 'select * from clre_limits_default;') %>%
tidyr::spread(technology, alert_limit)
df %<>%
dplyr::left_join(
y = limits,
by = c('technology', 'call_subject')
) %>%
dplyr::mutate(
alert_limit = dplyr::case_when(
.$technology == 'MicroSlide' & is.na(.$alert_limit) ~ defaults$MicroSlide,
.$technology == 'MicroTip' & is.na(.$alert_limit) ~ defaults$MicroTip,
.$technology == 'MicroWell' & is.na(.$alert_limit) ~ defaults$MicroWell,
TRUE ~ .$alert_limit
)
)
return(df)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.