The ln() function in R is “used to calculate the natural log of the input vector”. The default setting of the ln() function is to return the natural logarithm of a value.
Syntax
ln(x)
ln1p()
lg()
lg1p(x)
E
lb()
Parameters
x: It is a numeric or complex vector.
Examples
We define ln() and ln1p() as wrappers for log()“ with defaultbase = exp(1) argument and for log1p(), respectively.
The lg1p() is a convenient way to use the optimized code to calculate the logarithm of x + 1 but return the result in the base 10 logarithms.
R does not come with an ln() function but provides a log10() function.
To use the ln() function, use the SciViews package.
library("SciViews")
ln(exp(2))
ln1p(c(0, 1, 11, 110))
lg(11 ^ 3)
lg1p(c(0, 1, 11, 110))
E ^ 4
lb(1:4)
Output
[1] 2
[1] 0.0000000 0.6931472 2.4849066 4.7095302
[1] 3.124178
[1] 0.000000 0.301030 1.079181 2.045323
[1] 54.59815
[1] 0.000000 1.000000 1.584963 2.000000
E is the Euler constant and is equal to exp(1).
That’s it.

Krunal Lathiya is a Software Engineer with over eight years of experience. He has developed a strong foundation in computer science principles and a passion for problem-solving. In addition, Krunal has excellent knowledge of Data Science and Machine Learning, and he is an expert in R Language.