extract_digits: Extraction of First or Last Digits

View source: R/extract_digits.R

extract_digitsR 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)


digitTests documentation built on June 16, 2022, 5:11 p.m.