raw
Create a Raw Vector

### Description

Creates a vector with the element type raw.

### Usage

    raw(length = 0L)
    as.raw(x)
    is.raw(x)

### Arguments

length | an integer indicating the length of the vector to create.
x | an object.

### Details

raw creates a vector with the length length and an element type of "raw".
A raw vector is used to represent a "raw" sequence of bytes. Each byte is a value between 0 and 255. There are no NA values. Raw vectors are printed using hexadecimal (base 16) notation, so the (decial) value 10 is printed as 0a.
Value

raw() | returns a vector of mode "raw" and length of length.
as.raw() | returns a raw object if the original object x can be converted to a raw object. If it cannot be converted, an warning is displayed.
is.raw() | returns a logical value to indicate whether the object x is a raw object.

See Also
vector, serialize, charToRaw
Examples

    raw(2)
    # [1] 00 00
    as.raw(c(-1,0,10,255,256))
    #Warning: out-of-range values treated as 0 in coercion to raw
    # [1] 00 00 0a ff 00
    x <- runif(10)
    is.raw(x)
    # [1] FALSE
    # serialize an object into a vector of raw bytes
    r <- serialize(x, NULL)
    is.raw(r)
    # [1] TRUE
    # Re-create the object from the raw vector
    y <- unserialize(r)
    identical(x, y)
    # [1] TRUE
    # Convert a character string to raw bytes
    charToRaw('hello')
    # [1] 68 65 6c 6c 6f

Package base version 6.1.5-18
Package Index