logSpaced: Logarithmically spaced points

View source: R/logSpaced.R

logSpacedR Documentation

Logarithmically spaced points

Description

Calculates values that are in logarithmic distance from each other e.g. to produce logarithmic interval borders.
For exact logarithmic spacing, use 10^seq(from=log10(1), to=log10(100), len=100)

Usage

logSpaced(
  base = 1.1708,
  n = 20,
  min = 1,
  max = n,
  plot = TRUE,
  pch = 3,
  las = 1,
  ylab = "base",
  ...
)

Arguments

base

Base for calculations, can be a vector to compare several bases. DEFAULT: 1.1708

n

Number of values to be calculated. DEFAULT: 30

min, max

Range where n values are to be distributed, single values each. DEFAULT: 1,n

plot

Should the points be plotted on a line? DEFAULT: TRUE

pch, las

PointCharacter and Label Axis Style. DEFAULT: 3,1

ylab

Y axis label. DEFAULT: "base"

...

Further arguments passed to plot

Value

Vector or matrix, depending on base input

Note

base >1 concentrates points at low values, base<1 at high values. base does not relate to base in log!

Author(s)

Berry Boessenkool, berry-b@gmx.de, Oct 2014

See Also

classify, log, https://stackoverflow.com/a/29963530

Examples


logSpaced()
logSpaced(base=c(1.1, 1.5, 2), n=6, min=5, max=10)
d <- logSpaced(seq(0.8, 1.2, 0.025), main="logarithmically spaced points")

# the default base for the default n (20) will give an approximately equal
# bin width across the range on a logarithmic scale:
d <- logSpaced()
plot(d, rep(1,20), log="x")

# For exactly spacing logarithmically, use
plot(10^seq(from=log10(1), to=log10(100), len=100), log="y")


berryFunctions documentation built on April 12, 2023, 12:36 p.m.