Learn R Programming

tidyinftheo (version 0.2.1)

shannon_cond_entropy: Conditional Shannon Entropy H(X|Y) i.e. "H(X given Y)"

Description

This calculates conditional shannon entropy of two columns in a tibble. It's assumed these columns are character typed with no NAs.

Usage

shannon_cond_entropy(.data, ..., na.rm = FALSE)

Arguments

.data

A tibble with the columns of interest

...

two columns (variables) selected (order is important)

na.rm

remove all rows with NA values in at least one of the columns

Value

a double with the calculated value

See Also

shannon_entropy

Examples

Run this code
# NOT RUN {
# make an all-character version of mtchars
mt_tib <- as_tibble(mtcars) %>% mutate_all(as.character)
shannon_cond_entropy(mt_tib, vs, am)
shannon_cond_entropy(mt_tib, 'vs', 'am')
shannon_cond_entropy(mt_tib, starts_with('c'))
shannon_cond_entropy(mt_tib, 9:8)
# }

Run the code above in your browser using DataLab