What is the log() function in R?
Overview
The log() function in R is used to obtain the logarithm (the natural logarithm, by default) of a given input numeric or complex vector.
Syntax
log(x, base)
Syntax for the log() function
Parameter value
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 ofxis to be computed.
Return value
The log(0) function returns the logarithmic value in the specified base passed to it.
Code
# 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)