extractdigits: Extract first digits from user data

Description Usage Arguments Details Value References See Also Examples

Description

extractdigits extracts the first nonzero numdigits significant digits of the user's data, x.

Usage

1
extractdigits(x, numdigits = 1)

Arguments

x

Numeric matrix or vector.

numdigits

A positive integer, default is 1.

Details

"0" entries are omitted from the data.

The first n significant digits of a non-zero number are the first n non-zero digit of the number. For example, the first two significant digits of "012" are "12".

The first n significant digits of a number that has less than m < n digits is given by the m-digit number concatenated with (m-n) zeroes. For example, the first four significant digits of "1.2" are "1200".

Value

The output is a vector of first numdigits for nonzero entries in x (taken in column-major order if x is a matrix).

References

Lesperance M, Reed WJ, Stephens MA, Tsao C, Wilton B (2016) Assessing conformance with Benford's Law: goodness-of-fit tests and simultaneous confidence intervals. PLoS one; 11(3).

See Also

freqdigits

firstdigitsfreq

Examples

1
2
extractdigits(1:10, 1)
extractdigits(c(012, 1.2, 1, 0),2)

mlespera/BenGood documentation built on May 18, 2019, 3:43 p.m.