Learn R Programming

tidyinftheo (version 0.2.1)

shannon_entropy: Shannon Entropy H(X)

Description

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

Usage

shannon_entropy(.data, X, na.rm = FALSE)

Arguments

.data

A tibble with the column of interest

X

Name of the column

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_cond_entropy

Examples

Run this code
# NOT RUN {
shannon_entropy(iris, Species)
iris %>% as_tibble() %>% shannon_entropy(Species)
shannon_entropy(iris, 'Species')
shannon_entropy(iris, 5)
# }

Run the code above in your browser using DataLab