The log() function computes logarithms; by default, it calculates the natural logarithms. The log10() function computes common (for example, base 10) logarithms. The log2() function computes binary (i.e., base 2) logarithms. The common log(x, base) function computes logarithms with base.
log10 in R
The log10() is an inbuilt R mathematical function that calculates the base 10 logarithms. The log() function calculates natural logarithms by default. The log2() method computes the logarithm of the given column in base 2.
It takes x as a column to calculate.
Let’s find the log10 of 5 using the log10() function.
Let’s find the log10 value of 0 and 1.
 -Inf  0
Plot the log10() function in R
The most used plotting function in R programming is the plot() function. It is an inbuilt generic function with many methods called according to the type of object passed to the plot().
Open the rstudio and write the following code.
data <- seq(0, 1, by = 0.1) plot(data, log10(data), typ = "l", col = "red")
Find the log10() of the vector.
To find the log2 of the vector, pass the vector to the log10() function. Before that, you have to create a vector sequence if it is not available to you. Let’s create a vector sequence for our example.
vc <- (rep(1:5)) cat("The vector sequence is: ") cat(vc, "\n")
The vector sequence is: 1 2 3 4 5
To find the log10 of this vector, pass the sequence to a log10() function.
vc <- (rep(1:5)) cat("The vector sequence is: ") cat(vc, "\n") cat("Find the log10() of vector sequence is: ") cat(log10(vc))
The vector sequence is: 1 2 3 4 5 Find the log10() of vector sequence is: 0 0.30103 0.4771213 0.60206 0.69897
That is it for log10() function in R language.
Krunal Lathiya is an Information Technology Engineer by education and web developer by profession. He has worked with many back-end platforms, including Node.js, PHP, and Python. In addition, Krunal has excellent knowledge of Data Science and Machine Learning, and he is an expert in R Language. Krunal has written many programming blogs, which showcases his vast expertise in this field.