vfile: Create a custom file connection

vfileR Documentation

Create a custom file connection

Description

Create a custom file connection

Usage

vfile(description, open = "", verbosity = 1)

Arguments

description

path to a filename; contrary to rconnection a connection object is not supported.

open

character string. A description of how to open the connection if it is to be opened upon creation e.g. "rb". Default "" (empty string) means to not open the connection on creation - user must still call open(). Note: If an "open" string is provided, the user must still call close() otherwise the contents of the file aren't completely flushed until the connection is garbage collected.

verbosity

integer value 0, 1, or 2. Default: 1. Set to 0 for no debugging messages. Set verbosity = 2 for all debugging messages.

Details

This vfile() connection works like the file() connection in R itself.

This connection works with both ASCII and binary data, e.g. using readLines() and readBin().

Examples

## Not run: 
tmp <- tempfile()
dat <- as.raw(1:255)
writeBin(dat, vfile(tmp))
readBin(vfile(tmp),  raw(), 1000)

## End(Not run)

eddelbuettel/tldbr documentation built on Sept. 24, 2024, 5:28 a.m.