# Example 1a: Frequency table for 'cyl'
freq(mtcars$cyl)
# Example 1b: Alternative specification using the 'data' argument
freq(cyl, data = mtcars)
# Example 2: Frequency table, values shown in columns
freq(mtcars$cyl, val.col = TRUE)
# Example 3: Frequency table, use 3 digit for displaying percentages
freq(mtcars$cyl, digits = 3)
# Example 4a: Frequency table for 'cyl', 'gear', and 'carb'
freq(mtcars[, c("cyl", "gear", "carb")])
# Example 4b: Alternative specification using the 'data' argument
freq(cyl, gear, carb, data = mtcars)
# Example 5: Frequency table, with percentage frequencies
freq(mtcars[, c("cyl", "gear", "carb")], print = "all")
# Example 6: Frequency table, split output table
freq(mtcars[, c("cyl", "gear", "carb")], split = TRUE)
# Example 7: Frequency table, exclude variables with more than 5 unique values
freq(mtcars, exclude = 5)
if (FALSE) {
# Example 8a: Write results into a text file
freq(mtcars[, c("cyl", "gear", "carb")], split = TRUE, write = "Frequencies.txt")
# Example 8b: Write results into an Excel file
freq(mtcars[, c("cyl", "gear", "carb")], split = TRUE, write = "Frequencies.xlsx")
result <- freq(mtcars[, c("cyl", "gear", "carb")], split = TRUE, output = FALSE)
write.result(result, "Frequencies.xlsx")
}
Run the code above in your browser using DataLab