Learn R Programming

base (version 3.5.1)

rawConnection: Raw Connections

Description

Input and output raw connections.

Usage

rawConnection(object, open = "r")

rawConnectionValue(con)

Arguments

object

character or raw vector. A description of the connection. For an input this is an R raw vector object, and for an output connection the name for the connection.

open

character. Any of the standard connection open modes.

con

An output raw connection.

Value

For rawConnection, a connection object of class "rawConnection" which inherits from class "connection".

For rawConnectionValue, a raw vector.

Details

An input raw connection is opened and the raw vector is copied at the time the connection object is created, and close destroys the copy.

An output raw connection is opened and creates an R raw vector internally. The raw vector can be retrieved via rawConnectionValue.

If a connection is open for both input and output the initial raw vector supplied is copied when the connections is open

See Also

connections, showConnections.

Examples

Run this code
# NOT RUN {
zz <- rawConnection(raw(0), "r+") # start with empty raw vector
writeBin(LETTERS, zz)
seek(zz, 0)
readLines(zz) # raw vector has embedded nuls
seek(zz, 0)
writeBin(letters[1:3], zz)
rawConnectionValue(zz)
close(zz)
# }

Run the code above in your browser using DataLab