ln: Logarithms.

Description Usage Arguments Format See Also Examples

View source: R/ln.R

Description

To avoid confusion using the default log() function, which is natural logarithm, but spells out like base 10 logarithm in the mind of some beginneRs, we define ln() and ln1p() as wrappers for log()`` with defaultbase = exp(1)argument and forlog1p(), respectively. For similar reasons,lg()is a wrapper oflog10()(there is no possible confusion here, but 'lg' is another common notation for base 10 logarithm).lg1p()is a convenient way to use the optimized code to calculate the logarithm of x + 1, but returning the result in base 10 logarithm.Eis the Euler constant and is provided for convenience asexp(1). Finallylb()is a synonym oflog2()'.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
ln(x)

ln1p()

lg()

lg1p(x)

E

lb()

Arguments

x

A numeric or complex vector.

Format

An object of class numeric of length 1.

See Also

log()

Examples

1
2
3
4
5
6
ln(exp(3))              # Same as log(exp(3))
ln1p(c(0, 1, 10, 100))  # Wrapper for log1p()
lg(10^3)                # Same as log10(10^3)
lg1p(c(0, 1, 10, 100))  # log10(x + 1), but optimized for x << 1
E^4                     # Similar to exp(4), but different calculation!
lb(1:3)                 # Wrapper for log2()

Example output

[1] 3
[1] 0.0000000 0.6931472 2.3978953 4.6151205
[1] 3
[1] 0.000000 0.301030 1.041393 2.004321
[1] 54.59815
[1] 0.000000 1.000000 1.584963

SciViews documentation built on Nov. 17, 2019, 1:06 a.m.