| frequencyTable | R Documentation |
Counts the number of occurrences of the different values in each column of a data frame
frequencyTable(
data,
columns = names(data),
orderByLeastLevels = TRUE,
as.data.frame = TRUE,
useNA = c("no", "ifany", "always")[2]
)
data |
data frame |
columns |
columns of |
orderByLeastLevels |
if TRUE (default) the list elements in the output
list each of which represents one column of |
as.data.frame |
if TRUE (default) the result is a data frame, otherwise a list (see below) |
useNA |
passed to |
for as.data.frame = FALSE a list of data frames each of which
represents the frequency statistics for one column of data. Each
data frame has columns column (name of the column of data),
value (value occurring in column of data),
count (number of occurrences). For as.data.frame = TRUE one
data frame being the result of rbind-ing together these data frames.
# Some example data
(data <- data.frame(
A = c("a1", "a2", "a1", "a1", "a2", "", "a2", NA, "a1"),
B = c("b1", "b1", NA, "b2", "b2", "b1", " ", "b3", "b2")
))
frequencyTable(data) # results in a data frame
frequencyTable(data, as.data.frame = FALSE) # results in a list
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.