powered by
Calculates Shannon Entropy of a vector in bits (default) or natural units. Missing values are omitted from the calculation.
entropy(x, unit = c("bits"))
Entropy of input variable
Input vector
Unit to measure entropy. Either "bits" (default) or "nats".
Shannon, C. E. A mathematical theory of communication. The Bell System Technical Journal 27, 379–423 (1948).
# no entropy: vec <- c(1,1,1,1,1,1) entropy(vec) # entropy vec <- c(1,2,3,4,5,6) entropy(vec)
Run the code above in your browser using DataLab