#' @title sodium_trending
#'
#' @description Function to complete tracking and trending for Sodium complaints.
#'
#' @param sales_path Filepath to parsed sales data.
#'
#' @return Prints values to put into excel workbook.
#'
#' @export
sodium_trending <- function(
sales_path = NA
) {
if (is.na(sales_path)) {
sales_path <- file.path(
'L:', 'Rochester-Quality Regulatory Compliance', 'SRMS', 'SRMS Wrkspace',
'Customer Quality Monthly Analysis Reports', '2017 Reports and Data',
strftime(last_month(), format = '%m_%B'),
paste0('CL_Sales_', strftime(last_month(), format = '%b%Y'), '.xlsx')
)
}
sales_df <- openxlsx::read.xlsx(sales_path)
lastmon <- strftime(Sys.time() - months(2), '%Y%m')
inds <- match(lastmon, names(sales_df))
inds <- (inds-2):inds
sales <- round(mean(
colSums(sales_df[sales_df$product_code %in% c('8379034', '1532290'), inds])
))
df <- srms::roc_re_v26b()
total <- nrow(df %>%
dplyr::filter(
YYYYMM == max(YYYYMM),
Call_Subject == 'NA'
))
subtotal <- nrow(df %>%
dplyr::filter(
YYYYMM == max(YYYYMM),
Call_Subject == 'NA',
Call_Area %in% c('ACCH', 'ACCL', 'OutlierH', 'OutlierL',
'QCH', 'QCL', 'CORR')
))
sprintf('%i %i %i %f %f',
subtotal, total, sales, subtotal / sales * 1e6, total / sales * 1e6
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.