as_report_factor <- function(x) { levels_doc_name <- stringr::str_to_title(c( paste(c("first", "second", "third", "fourth"), "quarter"), paste(c("mid year", "year end"), "Semi-Annual") )) factor(x, levels_doc_name) }