pivot_table {kim} | R Documentation |
Pivot Table
Description
Create a pivot table.
Usage
pivot_table(
data = NULL,
row_names = NULL,
col_names = NULL,
function_as_character = NULL,
sigfigs = 3,
output = "dt",
remove_col_names = TRUE
)
Arguments
data |
a data object (a data frame or a data.table) |
row_names |
names of variables for constructing rows |
col_names |
names of variables for constructing columns independent variables |
function_as_character |
function to perform for each cell in the pivot table |
sigfigs |
number of significant digits to which to round values in the pivot table (default = 3) |
output |
type of output. If |
remove_col_names |
logical. Should the column names (i.e., v1, v2, ...) be removed in the data table output? |
Value
the output will be a contingency table in a data.table format
Examples
pivot_table(
data = mtcars, col_names = "am", row_names = c("cyl", "vs"),
function_as_character = "mean(mpg)")
pivot_table(
data = mtcars, col_names = "am", row_names = c("cyl", "vs"),
function_as_character = "sum(mpg < 17)")
pivot_table(
data = mtcars, col_names = "am", row_names = c("cyl", "vs"),
function_as_character =
"round(sum(mpg < 17) / sum(!is.na(mpg)) * 100, 0)")
[Package kim version 0.5.422 Index]