numIn: Extract numbers in character strings

Description Usage Arguments Examples

Description

Extract numbers in character strings

Usage

1
numIn(x, simplify = FALSE)

Arguments

x

Atomic vector or list.

simplify

Logical or character string. Should the result be simplified to a vector, matrix or higher dimensional array if possible?

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Atomic character
x <- levels(cut(1:100, 3))
(out <- numIn(x))

# Atomic factor is coerced to character
x <- unique(cut(1:100, 3))
identical(numIn(x), out) 	# TRUE

# Works on list as well
x <- do.call(list, as.list(x))
identical(numIn(x), out) 	# TRUE

# When type is not character or factor the names are used
x <- do.call(list, as.list(1:3))
names(x) <- unique(cut(1:100, 3))
identical(numIn(x), out) 	# TRUE

# If names is NULL or empty the row.names are used instead
x <- matrix(1:6, 3)
row.names(x) <- levels(cut(1:100, 3))
is.null(names(x)) 		# TRUE
identical(numIn(x), out) 	# TRUE

SESman/rbl documentation built on May 9, 2019, 11:10 a.m.