variable_entropy {eHDPrep}R Documentation

Calculate Entropy of Each Variable in Data Frame

Description

Calculates Shannon entropy of all variables in a data frame in bits (default) or natural units. Missing values are omitted from the calculation.

Usage

variable_entropy(data, unit = "bits")

Arguments

data

Data Frame to compute on

unit

Unit to measure entropy. Either "bits" (default) or "nats".

Value

Named numeric vector containing entropy values

References

Shannon, C. E. A mathematical theory of communication. The Bell System Technical Journal 27, 379–423 (1948).

Examples

a <- matrix(c(c(1,1,1,1,1,1, 1,2,3,4,5,6)),ncol = 2, dimnames =
list(seq(1,6), c("no_entropy","entropy")))
variable_entropy(as.data.frame(a))

[Package eHDPrep version 1.3.3 Index]