Is it possible to customize the headings portion printed with the freq()
and descr()
functions in the summarytools R package?
Ultimately, my aim here is to make headings above my freq()
or descr()
rmarkdown outputs. (I don't mean the # style markdown headings.) So maybe if I cannot customize these function outputs, is there a way I could add custom text as a heading directly above the output so in rmarkdown for a seemless look?
Looks like I can either keep or discard the output headings with headings=FALSE
but not customize it. Data & code example below.
Goals:
- Write my own name(s) for the variable(s) expressed in the output.
- Remove the default type of function, coded variable name, and type of variable.
- Use these changes in rmarkdown.
I've looked through the function help docs and few design vignettes such as Summarytools in R Markdown Documents by Dominic Comtois, but maybe I'm missing something.
toy <- data.frame(x=c("a","b","c","a","b","a"))
freq(toy$x, cumul=FALSE)
# output:
#Frequencies
#toy$x
#Type: Character
#
# Freq % Valid % Total
#----------- ------ --------- ---------
# a 3 50.00 50.00
# b 2 33.33 33.33
# c 1 16.67 16.67
# <NA> 0 0.00
# Total 6 100.00 100.00
freq(toy$x, cumul=FALSE, headings=FALSE)
#output:
# Freq % Valid % Total
#----------- ------ --------- ---------
# a 3 50.00 50.00
# b 2 33.33 33.33
# c 1 16.67 16.67
# <NA> 0 0.00
# Total 6 100.00 100.00
#EXAMPLE GOAL:
#Letter Groups
# Freq % Valid % Total
#----------- ------ --------- ---------
# a 3 50.00 50.00
# b 2 33.33 33.33
# c 1 16.67 16.67
# <NA> 0 0.00
# Total 6 100.00 100.00