The log10()
function in R uses base 10 to calculate the logarithm of a number.
Figure 1 below shows the mathematical representation of the log10()
function and the corresponding representation in R.
R is a programming language based on statistical computing and graphics.
log10(number)
This function requires a number whose logarithm base 10 must be calculated, and it must be greater than zero.
If the number is zero
, then this function outputs -Inf
.
If the number is negative
, this function outputs NaN
along with a warning message.
log10()
uses base 10 to return the logarithm of a number.
The following example shows how to use the log10()
function in R:
a <- log10(10);print(paste0("log10(10): ", a))b <- log10(2);print(paste0("log10(2): ", b))c <- log10(15.2);print(paste0("log10(15.2): ", c))#error outputsd <- log10(0);print(paste0("log10(0): ", d))e <- log10(-1);print(paste0("log10(-1): ", e))