as_writer turns an existing object into a writeable stream. Coercion can be used when you want to write to a known data sink In general, this is the easiest way to create a writeable stream.

As an S3 generic, as_writer holds methods for:

  • character: creates a stream that appends all chunks to a variable specified by the character input

  • connection: write to a file, coercing chunks to a character vector where required

  • default: throws an error

as_writer(x, queue_strategy)

Arguments

x

object to coerce

queue_strategy

optionally specify the queue strategy of the stream

Examples

# create a writeable stream from a file path
writer <- as_writer(file(tempfile()))