spatstat.utils (version 1.13-0)

spatstat.utils-package: The spatstat.utils Package

Description

The spatstat.utils package contains low-level utilities, written for the spatstat package, which may be useful in other packages as well.

Arguments

Licence

This library and its documentation are usable under the terms of the “GNU General Public License”, a copy of which is distributed with R.

Details

The functions in spatstat.utils were originally written as internal, undocumented, utility functions in the spatstat package.

Many of these functions could be useful to other programmers, so we have made them available in a separate package spatstat.utils and provided documentation.

The functionality contained in spatstat.utils includes:

Factorisation of integers

Find prime numbers (primesbelow), factorise a composite number into its prime factors (primefactors), determine whether a number is prime (is.prime) or whether two numbers are relatively prime (relatively.prime), and find the least common multiple or greatest common divisor of two numbers (least.common.multiple, greatest.common.divisor).

Faster versions of basic R tools

Faster versions of some basic R tools and idioms are provided. These are only faster in particular cases, but if you know that your data have a particular form, the acceleration can be substantial. See ifelseAB, fave.order, revcumsum, tapplysum.

Grammar

Use the correct word in English to refer to an ordinal number (ordinal, ordinalsuffix) and the correct indefinite article (articlebeforenumber).

Tools for generating printed output

The function splat is a replacement for cat(paste(…)) which ensures that output stays inside the declared text margin (getOption("width")) and can also perform automatic indentation. There are useful functions to add or remove parentheses (paren, unparen) and to make comma-separated lists (commasep).

Handling intervals (ranges) of real numbers

Simple functions handle an interval (range) of numerical values: check.range, intersect.ranges, inside.range, check.in.range, prange.

Handling a formula

Tools for handling a formula in the R language include lhs.of.formula, rhs.of.formula, variablesinformula, termsinformula, offsetsinformula, can.be.formula and identical.formulae.

Polynomials

There are tools for creating and manipulating symbolic expressions for polynomials, as they might appear in a formula (sympoly, expand.polynom).

Validating arguments

There are many tools for validating an argument and generating a comprehensible error or warning message if the argument is not valid: check.1.integer, check.nvector, check.named.vector.

Passing arguments

There are many tools for calling a function while passing only some of the arguments in a supplied list of arguments: do.call.matched, do.call.without, resolve.defaults.

Traced optimization

optimizeWithTrace is a simple wrapper for the one-dimensional optimization routine optimize. It stores the values of the function argument each time it is called, stores the resulting function values, and returns them along with the optimal value.

Workarounds

There are workarounds for known bugs or undesirable features in other software. spatstatLocator is a replacement for locator which works around a bug in the RStudio graphics interface. cat.factor concatenates several factors, merging the levels, to produce a new factor.