extract_digits {digitTests}R Documentation

Extraction of First or Last Digits

Description

This function extracts the first (and optionally second) or last digits in a vector.

Usage

extract_digits(x, check = 'first', include.zero = FALSE)

Arguments

x

a numeric vector.

check

location of the digits to extract. Can be first, firsttwo, or last.

include.zero

logical. Whether to include the digit zero in the output.

Value

A vector of first (and optionally second) or last digits.

Author(s)

Koen Derks, k.derks@nyenrode.nl

Examples

set.seed(1)
x <- rnorm(100)

# Extract first digits (without zero)
extract_digits(x, check = 'first')

# Extract last digits (including zero)
extract_digits(x, check = 'last', include.zero = TRUE)


[Package digitTests version 0.1.2 Index]