Keywords: classes
### ** Examples xx <- raw(2) xx[1] <- as.raw(40) # NB, not just 40. xx[2] <- charToRaw("A") xx ## 28 41 -- raw prints hexadecimals
[1] 28 41
dput(xx) ## as.raw(c(0x28, 0x41))
as.raw(c(0x28, 0x41))
as.integer(xx) ## 40 65
[1] 40 65
x <- "A test string" (y <- charToRaw(x))
[1] 41 20 74 65 73 74 20 73 74 72 69 6e 67
is.vector(y) # TRUE
[1] TRUE
rawToChar(y)
[1] "A test string"
is.raw(x)
[1] FALSE
is.raw(y)
[1] TRUE
stopifnot( charToRaw("\xa3") == as.raw(0xa3) ) isASCII <- function(txt) all(charToRaw(txt) <= as.raw(127)) isASCII(x) # true
[1] TRUE
isASCII("\xa325.63") # false (in Latin-1, this is an amount in UK pounds)
[1] FALSE