R/BioCG_1_cat.r

Defines functions BioCG_1_cat

Documented in BioCG_1_cat

#' Summarize one categorical variable

#' @export

BioCG_1_cat <- function(x,the_var="variable"){

the_result_1 <- janitor::tabyl(x) %>%
  dplyr::mutate(percent = paste0(round(percent*100,3),"%"),
                !!the_var := paste0(n,paste0("(",percent,")")))

the_result_2 <- setNames(data.frame(t(the_result_1[,-1])),the_result_1[,1])

the_result_3 <- the_result_2[the_var,]

return(the_result_3)
}
AndrewH6/BioCG documentation built on Dec. 17, 2021, 8:50 a.m.