Add Variable Labels Using the Summarytools Freq Package
I Want to Add Variable Labels to the Frequency Tables That I Generated. But, I Can't Find That Functionality in the Summarytools Documentation. Here Is My...
I want to add variable labels to the frequency tables that I generated. But, I can't find that functionality in the summarytools documentation.
Here is my code:
the data
library(magrittr)
library(dplyr)
library(gtsummary)
library(summarytools)
require(pander)
library(knitr)
library(stringr)
data_in_na <- readr::read_table2('q1 q2
No somelongresponsethattakesupmorethanonline--somelongresponsethattakesupmorethanonline
No somelongresponsethattakesupmorethanonline--somelongresponsethattakesupmorethanonline
No somelongresponsethattakesupmorethanonline--somelongresponsethattakesupmorethanonline
No somelongresponsethattakesupmorethanonline--somelongresponsethattakesupmorethanonline
No Yes
No Always
Yes No
Yes No
Yes No
NA NA
NA NA
NA NA
NA NA
')
vct <- data_in_na %>% names(.)
Must Read
function to create frequencies
create_freq <- function(v1) {
#names <- c("var name 1", "var name 2")
freq(v1,
cumul = FALSE,
totals = TRUE,
display.type = FALSE,
variable.label = v1,
missing ='missing',
report.nas = TRUE)
}