Konversi dan manipulasi objek bertipe "mentah".
charToRaw(x)
rawToChar(x, multiple = FALSE)<p></p><p>rawShift(x, n)</p><p>rawToBits(x)
intToBits(x)
packBits(x, type = c("raw", "integer"))</p>
| Parameter | Deskripsi |
|---|---|
x |
object to be converted or shifted. |
multiple |
logical: should the conversion be to a single character string or multiple individual characters? |
n |
the number of bits to shift. Positive numbers shift right and negative numbers shift left: allowed values are -8 ... 8. |
type |
the result type, partially matched. |
# NOT RUN {
x <- "A test string"
(y <- charToRaw(x))
is.vector(y) # TRUE
rawToChar(y)
rawToChar(y, multiple = TRUE)
(xx <- c(y, charToRaw("&"), charToRaw("more")))
rawToChar(xx)
rawShift(y, 1)
rawShift(y, -2)
rawToBits(y)
showBits <- function(r) stats::symnum(as.logical(rawToBits(r)))
z <- as.raw(5)
z ; showBits(z)
showBits(rawShift(z, 1)) # shift to right
showBits(rawShift(z, 2))
showBits(z)
showBits(rawShift(z, -1)) # shift to left
showBits(rawShift(z, -2)) # ..
showBits(rawShift(z, -3)) # shifted off entirely
# }