###########################################################################################################################################################
#' Rank to Paygrades
#'
#' @param df a dataframe of ranks and possibly services
#' @param service either "Multi", in which case columns "service" and "rank" must be present in df, or one of "Army", "Air Force", "Navy", "Coast Guard", in which case column rank must be present in df
#'
#' @return This function returns a dataframe with an additional column for paygrade
#'
#' @author Bjorn Kallerud
#'
#' @import dplyr
#'
#' @export
rank_to_pg <- function(df, srvc) {
if (srvc != "Multi") {
df_out <- df %>%
left_join(df_rank_pg %>% filter(service == srvc) %>% select(-service), by = c("rank"))
}
if (srvc == "Multi") {
df_out <- df %>%
left_join(df_rank_pg, by = c("service", "rank"))
}
if (nrow(df_out) > nrow(df)) {warning("Match is not unique.")}
return(df_out)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.