#' Format coefficient table
#'
#'\code{coef_format} takes the tibble of coefficients and p.values
#'from a tidy call, and roudns to 3 dp and adds stars as a column.
#'
#' @param df A tibble from a tidy broom call
#' @param ... Extra calls to round.
#'
#' @return A tibble
#' @export
#'
#' @examples
#'
#' all_data_wide %>% filter(Treatment != "CON") %>%
#' group_by(Host, Treatment) %>%
#' do(tidy(glm(Inf_rate ~ MRS2, data = ., family = binomial()))) %>%
#' format_num()
coef_format <- function(df, ...) {
df <- df %>%
mutate_if(is.numeric, round, digits = 3, ...) %>%
mutate(signif = ifelse(p.value > 0.1, "",
ifelse(p.value <= 0.1 & p.value > 0.05, ".",
ifelse(p.value <= 0.05 & p.value > 0.01, "*",
ifelse(p.value <= 0.01 & p.value > 0.001, "**", "***")))))
return(df)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.