cat_summarise {tabbycat}R Documentation

Summarise the values of a numerical variable for each group within a categorical variable

Description

The results are sorted on the values of the categorical variable i.e. the variable specified with cat. If this variable is a character vector it will be sorted alphabetically. If it is a factor it will be sorted in the order of its levels. This function can be called as either cat_summarise or cat_summarize.

Usage

cat_summarise(
  data,
  cat,
  num,
  na.rm = FALSE,
  clean_names = getOption("tabbycat.clean_names")
)

cat_summarize(
  data,
  cat,
  num,
  na.rm = FALSE,
  clean_names = getOption("tabbycat.clean_names")
)

Arguments

data

A dataframe containing a categorical variable and numerical variable to summarise.

cat

The name of a column in data which is a categorical vector of discrete values for which summaries will be calculated.

num

The name of a column in data which is a numerical vector that will be summarised for each group.

na.rm

A boolean indicating whether to exclude NAs from the row results. Note that NAs are **always** ignored in calculating the summary statistics for num shown in each row, and the number of NAs that exist in num for each group in cat is shown in the na column of the results table. This argument controls whether a row of summary statistics is shown for observations that are NA in cat. The default is FALSE.

clean_names

A boolean indicating whether the column names of the results tibble should be cleaned, so that any column names produced from data are converted to snake_case. The default is TRUE, but this can be changed with options(tabbycat.clean_names = FALSE).

Value

A tibble showing summary statistics for num for each group in cat.


[Package tabbycat version 0.18.0 Index]