# Example usage:
library(dplyr)
# Sample dataset
data1 <- data.frame(
group = c("A", "B", "B", "C"),
var1 = c(1, 2, 3, NA),
var2 = c("X", "Y", "X", NA)
)
# Generate descriptive table
table <- desc_var(
data1 = data1,
table_title = "Descriptive Table",
quanti = "var1"
)
# Order categorical features by frequency
table1 <- desc_var(
data1 = data1,
table_title = "Descriptive Table",
quanti = "var1",
freq_relevel = TRUE)
# Round quantitative and qualitative features using a vector of integer
table2 <- desc_var(
data1 = iris,
quanti = "Sepal.Length",
stat_var_quanti = c("{sum}", "{mean} ({sd})"),
digits = list(r_quanti = c(1, 3, 2), r_quali = c(0, 2))
)
Run the code above in your browser using DataLab