rt_explore_value_totals: returns either a *count* of the unique values of 'variable'...

View source: R/explore_basics.R

rt_explore_value_totalsR Documentation

returns either a *count* of the unique values of 'variable' if 'sum_by_variable' is NULL, otherwise it *sums* the variable represented by 'sum_by_variable' across (i.e. grouped by) 'variable'

Description

If 'multi_value_delimiter' is not NULL, then it counts all the values found after it splits/separates the variable by the delimiter. If 'sum_by_variable' is NULL, it counts the values and the denominator for the 'percent' column returned is the total number of records. If 'sum_by_variable' is not NULL, then when multiple values are found, each value is weighted by the value found in 'sum_by_variable', and the denominator for the 'percent' column returned is the 'sum' of 'sum_by_variable' (before the values are split).

Usage

rt_explore_value_totals(
  dataset,
  variable,
  second_variable = NULL,
  facet_variable = NULL,
  count_distinct = NULL,
  sum_by_variable = NULL,
  multi_value_delimiter = NULL
)

Arguments

dataset

dataframe containing numberic columns

variable

the variable (e.g. factor) to get unique values from

second_variable

group by a second variable

facet_variable

group by a third variable. However, the 'percent' & 'group percent' are still relative to only 'variable' & 'second_variable' which is NOT equivalent to grouping by a third variable and calculating the percent of all the data. 'percent' will sum to 1 for each facet value. The naming convention for appearing in the table will be '[variable name] - [variable - value]'. This variable is meant to correspond to faceting the data in a graph.

count_distinct

count the distinct number of values in this column

sum_by_variable

the numeric variable to sum

multi_value_delimiter

if the variable contains multiple values (e.g. "A", "A, B", ...) then setting this variable to the delimiter will cause the function to count seperate values

Examples


library(ggplot2)
rt_explore_value_totals(dataset=iris, variable='Species')


shane-kercheval/rtools documentation built on July 7, 2022, 8:31 a.m.