filesstrings (version 3.0.0)

extract_numbers: Extract numbers from a string.

Description

See strex::str_extract_numbers().

Usage

extract_numbers(string, leave_as_string = FALSE, decimals = FALSE,
  leading_decimals = FALSE, negs = FALSE)

nth_number(string, n, leave_as_string = FALSE, decimals = FALSE, leading_decimals = FALSE, negs = FALSE)

first_number(string, leave_as_string = FALSE, decimals = FALSE, leading_decimals = FALSE, negs = FALSE)

last_number(string, leave_as_string = FALSE, decimals = FALSE, leading_decimals = FALSE, negs = FALSE)

Arguments

string

A string.

leave_as_string

Do you want to return the number as a string (TRUE) or as numeric (FALSE, the default)?

decimals

Do you want to include the possibility of decimal numbers (TRUE) or not (FALSE, the default).

leading_decimals

Do you want to allow a leading decimal point to be the start of a number?

negs

Do you want to allow negative numbers? Note that double negatives are not handled here (see the examples).

n

The index of the number (or non-numeric) that you seek. Negative indexing is allowed i.e. n = 1 (the default) will give you the first number (or non-numeric) whereas n = -1 will give you the last number (or non-numeric), n = -2 will give you the second last number and so on. The function is vectorized over this argument.