numeric_string {cwhstring}R Documentation

Test string for being a number or made up of digits only, convert to bases.

Description

numeric_string Test whether the elements of a character vector represent legal numbers only. all_digits Test whether the elements of a character vector consist of digits only intToASCII Show character or octal representation at a place in the ASCII sequence intToBase Convert an integer number to string representation in a base between 2 and 16 inclusive intToOct Convert an integer number to string representation in octal intToHex Convert an integer number to string representation in hexadecimal

Usage

numeric_string(str)
all_digits(str)
intToASCII(i)
intToBase(i,Base=2)
intToOct(i)
intToHex(i)

Arguments

str A character vector.
i Integer number to be converted.
Base Number base to be converted to.

Value

TRUE, FALSE string representation

Author(s)

Christian W. Hoffmann, christian.hoffmann@wsl.ch, http://www.wsl.ch/staff/christian.hoffmann

Examples

all_digits(c("1231","89a8742")) #  TRUE FALSE
numeric_string(c("1231","8.9e-2",".7d2")) # [1]  TRUE  TRUE FALSE
intToASCII(1:255)
sapply(1:50,intToBase,2)
sapply(1:50,intToBase,7)
sapply(1:50,intToOct)
sapply(1:50,intToHex)

[Package cwhstring version 2.0 Index]