probabilitiesFromDiscrete: Helper function to calculate probability from discrete data...

View source: R/tidyConvertToProbabilities.R

probabilitiesFromDiscreteR Documentation

Helper function to calculate probability from discrete data in a tidy friendly manner

Description

The purpose of this is to calculate the probabilities of events from discrete data. This function is useful when you have either a set of observations of its occurrence, containing non-unique x events, or you have a counts of their events where each row has the type of observation of X=x and the countVar column contains the counts of the event.

Usage

probabilitiesFromDiscrete(df, discreteVars, sampleVars, countVar = NULL)

Arguments

df

a dataframe containing columns defining class of observations of discrete variable X and either one row per observation, or a count of observations for each of the observed values of X. df may be grouped and in which case the grouping defines the top level - usually this is the feature under investigation

discreteVars

the datatable column(s) defining the class of the discrete variable observed quoted by vars(...)

sampleVars

the datatable column(s) defining the id of each sample the observation quoted by vars(...)

countVar

the datatable column containing the observed frequency of the event X. If this is missing the row count will be used instead.

Value

A summary datatable with possible values of X and the total (N), the total count of that group (N_x) the probability (p_x), and self information (I_x) associated with the value of X


terminological/tidy-info-stats documentation built on Nov. 19, 2022, 11:23 p.m.