The log()
function in R is used to obtain the logarithm (the natural logarithm, by default) of a given input numeric or complex vector.
log(x, base)
The log()
function takes the following parameter values:
x
: This is the numeric or complex vector whose logarithm is to be obtained.base
: This is a positive or complex number that represents the base at which the logarithm of x
is to be computed.The log(0)
function returns the logarithmic value in the specified base
passed to it.
# creating a numeric vectorx = 100# taking the logarithm of x in base 2log(x, 2)# taking the logarithm of x in base 10log(x, 10)# taking the natural logarithm of xlog(x)