| pivot_table | R Documentation | 
Create a pivot table.
pivot_table(
  data = NULL,
  row_names = NULL,
  col_names = NULL,
  function_as_character = NULL,
  sigfigs = 3,
  output = "dt",
  remove_col_names = TRUE
)
| 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? | 
the output will be a contingency table in a data.table format
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)")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.