numericString {cwhmisc}R Documentation

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

Description

Functions for testing strings and for conversion of integers to bases other than decimal as string representations.

Usage

numericString(str)
allDigits(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.

Details

numericString Test whether the elements of a character vector represent legal numbers only. allDigits 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.

Value

TRUE, FALSE, string representations

Author(s)

Christian W. Hoffmann <c-w.hoffmann@sunrise.ch>
http://www.wsl.ch/personal_homepages/hoffmann/index_EN

Examples

allDigits(c("1231","89a8742")) #  TRUE FALSE
numericString(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 cwhmisc version 2.0.1 Index]