# Example data frame
my_data <- dummy_data(1000)
# Define titles and footnotes. If you want to add hyperlinks you can do so by
# adding "link:" followed by the hyperlink to the main text.
titles <- c("This is title number 1 link: https://cran.r-project.org/",
"This is title number 2",
"This is title number 3")
footnotes <- c("This is footnote number 1",
"This is footnote number 2",
"This is footnote number 3 link: https://cran.r-project.org/")
# Output frequency tables
my_data |> frequency(sex)
my_data |> frequency(c(age, education),
weight = weight)
# Also works with characters
my_data |> frequency("sex")
my_data |> frequency(c("age", "education"),
weight = "weight")
# Applying formats and titles
sex. <- discrete_format(
"Total" = 1:2,
"Male" = 1,
"Female" = 2)
my_data |> frequency(sex, formats(sex = sex.),
titles = titles,
footnotes = footnotes)
# Split frequencies by expressions of another variable
my_data |> frequency(sex, by = education)
# Get a list with two data tables for further usage
result_list <- my_data |> frequency(sex, formats(sex = sex.))
# Output in text file
my_data |> frequency(sex, output = "text")
# Output to Excel
my_data |> frequency(sex, output = "excel")
# With individual styling
my_style <- excel_output_style(header_back_color = "0077B6",
font = "Times New Roman")
my_data |> frequency(sex, output = "excel", style = my_style)
Run the code above in your browser using DataLab