probabilitiesFromCooccurrence: Helper function to calculate probability from grouped data in...

View source: R/tidyConvertToProbabilities.R

probabilitiesFromCooccurrenceR Documentation

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

Description

The purpose of this is to calculate the probabilities of all binary outcomes from class data. This function is useful when you have 2 types of events (X and Y) and you either have a set of observations of their co-occurrence, containing non-unique X & Y combinations, or you have a confusion matrix of the counts of their combinations where each row has a unique combination of X and Y and a third column contains the counts of XY co-occurrences.

Usage

probabilitiesFromCooccurrence(df, groupXVars, groupYVars, countVar = NULL)

Arguments

df

a dataframe containing 2 columns defining class of event X and class of event Y and either one row per event, or a count of observations, for each class combination. df may also be grouped and in which case the grouping is preserved in the result.

groupXVars

the datatable column(s) defining the class of event X quoted by vars(...)

groupYVars

the datatable column(s) defining the class of event Y quoted by vars(...)

countVar

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

Value

A new datatable with all possible combinations of X&Y and the probabilities associated with each outcome (i.e. an N(X) by N(Y) set of binary confusion matrices)


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