log10()

log10(x)
Returns: numeric · Updated March 13, 2026 · Base Functions
math log log10 logarithm base

The log10() function computes the logarithm of a number in base 10.

Syntax

log10(x)

Parameters

ParameterTypeDefaultDescription
xnumericA numeric vector or scalar

Examples

Basic usage

# Log base 10 of 10 is 1
log10(10)
# [1] 1

# Log base 10 of 100 is 2
log10(100)
# [1] 2

# Log base 10 of 1000 is 3
log10(1000)
# [1] 3

# Working with vectors
log10(c(1, 10, 100, 1000))
# [1] 0 1 2 3

Scientific notation

# Useful for scientific notation
log10(1e6)
# [1] 6

log10(3.14159)
# [1] 0.4971499

pH calculation

# Calculate pH from hydrogen ion concentration
h_concentration <- 1e-7
pH <- -log10(h_concentration)
pH
# [1] 7

Common Patterns

Order of magnitude

# Determine order of magnitude
x <- c(0.001, 0.01, 0.1, 1, 10, 100, 1000)
floor(log10(x))
# [1] -3 -2 -1  0  1  2  3

Decibel calculations

# Power ratio to decibels
power_ratio <- 1000
10 * log10(power_ratio)
# [1] 30

See Also