rawConversion(base)
rawConversion()所属R语言包:base
Convert to or from Raw Vectors
转换或从原始向量
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Conversion and manipulation of objects of type "raw".
类型"raw"对象的转换和操纵。
用法----------Usage----------
charToRaw(x)
rawToChar(x, multiple = FALSE)
rawShift(x, n)
rawToBits(x)
intToBits(x)
packBits(x, type = c("raw", "integer"))
参数----------Arguments----------
参数: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.
移位的位数。正数转向权利和负数左移:允许的值是-8 ... 8。
参数:type
the result type.
结果类型。
Details
详情----------Details----------
packBits accepts raw, integer or logical inputs, the last two without any NAs.
packBits接受原料,整数或逻辑输入,最后两个没有任何NAS。
值----------Value----------
charToRaw converts a length-one character string to raw bytes. It does so without taking into account any declared encoding (see Encoding).
charToRaw长度原始字节字符串转换。它这样做,而不考虑任何声明的编码(见Encoding)。
rawToChar converts raw bytes either to a single character string or a character vector of single bytes (with "" for 0). (Note that a single character string could contain embedded nuls; only trailing nulls are allowed and will be removed.) In either case it is possible to create a result which is invalid in a multibyte locale, e.g. one using UTF-8.
rawToChar原始字节转换到一个字符串或一个单字节的字符向量(用""0)。 (注:一个字符串可能包含嵌入式nuls;只落后空是允许的,将被删除。)在这两种情况下,它可以创建一个结果是无效的多字节语言环境中,例如使用UTF-8。
rawShift(x,n) shift the bits in x by n positions to the right, see the argument n, above.
rawShift(x,n)位xn位置转移到右侧,看到的说法n上面。
rawToBits returns a raw vector of 8 times the length of a raw vector with entries 0 or 1. intToBits returns a raw vector of 32 times the length of an integer vector with entries 0 or 1. (Non-integral numeric values are truncated to integers.) In both cases the unpacking is least-significant bit first.
rawToBits返回的8倍,与0或1项的原始向量的长度的原始向量。 intToBits返回的条目0或1的整数向量的长度32倍的原始向量。 (非整数值将被截断为整数)。在这两种情况下开箱首先是最低有效位。
packBits packs its input (using only the lowest bit for raw or integer vectors) least-significant bit first to a raw or integer vector.
packBits包其输入(使用原料或整数向量只有最低位)最低有效位在前原料或整数向量。
举例----------Examples----------
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[转向完全关闭]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|