$$H(X) = -\sum_x p(x)\log p(x)$$ Shannon (1948), Section 6; Cover & Thomas (2006), eq. (2.1). Counts are accepted as well as probabilities: the input is closed first.
Examples
Shanent(c(1, 1, 1, 1))
#> $estimate
#> [1] 2
#>
#> $hmax
#> [1] 2
#>
#> $evenness
#> [1] 1
#>
#> $n
#> [1] 4
#>
#> $method
#> [1] "Shannon entropy of a discrete distribution -- Shannon (1948) Sec. 6"
#>
