Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

digits

Test, convert numbers


Description

Test, convert numbers

Usage

allDigits( str, base=10 )
  isNumeric(str)
  str2dig( str )

Arguments

str

Vector of strings

base

Integer, base of number representation used in r2B

Value

allDigits The strings contain digits only which are allowable in base 'base'.
isNumeric Test whether the elements of a character vector represent legal numbers only.
str2dig Convert a string to a vector of integers.

Author(s)

Christian W. Hoffmann <christian@echoffmann.ch>

Examples

allDigits(c("1231","89a8742")) #  TRUE FALSE
  isNumeric(c("1231","8.9e-2",".7d2")) # [1]  TRUE  TRUE FALSE
  str2dig("13245.") #  1 3 2 4 5 NA
    # for comparison, big numbers:
  int(10^(7:10)) # 10000000 100000000 1000000000 NA

cwhmisc

Miscellaneous Functions for Math, Plotting, Printing, Statistics, Strings, and Tools

v6.6
GPL (>= 2)
Authors
Christian W. Hoffmann
Initial release
2018-08-24, 10:40:10

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.