#' @title FUNCTION_TITLE
#' @description FUNCTION_DESCRIPTION
#' @param tbl PARAM_DESCRIPTION
#' @param nest_id PARAM_DESCRIPTION
#' @param yvar PARAM_DESCRIPTION
#' @param measure PARAM_DESCRIPTION
#' @param facet PARAM_DESCRIPTION
#' @return OUTPUT_DESCRIPTION
#' @details DETAILS
#' @examples
#' \dontrun{
#' if(interactive()){
#' #EXAMPLE1
#' }
#' }
#' @rdname facet_col_plot
#' @export
#' @importFrom scales comma
#' @importFrom dplyr slice_max
#' @importFrom dplyr mutate
#' @importFrom forcats fct_reorder
#' @import ggplot2
#' @importFrom tidytext reorder_within
#' @importFrom tidytext scale_y_reordered
facet_col_plot <- function(tbl, nest_id, yvar, measure, facet){
tbl%>%
mutate(yvar = reorder_within({{ yvar }}, by= {{ measure }}, within= {{ facet }}))%>%
ggplot(aes({{ measure }}, yvar)) +
geom_col() +
scale_x_continuous() +
scale_y_reordered() +
facet_wrap(vars({{ facet }}), scales = "free_y") +
labs(y = "",
title=nest_id)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.