read_write_option: Define default read/write options and add items to it

View source: R/read_write_option.R

read_write_optionR Documentation

Define default read/write options and add items to it

Description

Define the functions that read() or write() must call to import or export data for the different types (formats).

Usage

read_write_option(new_type)

Arguments

new_type

A data.frame with four columns: type, read_fun, read_header and write_fun containing each a single character string or NA. type is the usual extension for this type of file, e.g., png for PNG images, read_fun, read_header and write_fun are character strings with "pkg::fun" format ("pkg" is the package containing the function and "fun" is the function name), or just "fun" if the function is visible on the search path.

Value

The data.frame with all known formats is returned invisibly. The same data.frame is also saved in the ⁠read_write`` option, and can be retrieved directly with ⁠getOption("read_write")'.

Author(s)

Philippe Grosjean phgrosjean@sciviews.org

See Also

read(), getOption()

Examples

# The default options
(read_write_option())
# To add a new type:
tail(read_write_option(data.frame(type = "png", read_fun = "png::readPNG",
  read_header = NA, write_fun = "png::writePNG", comment = "PNG image")))

SciViews/data.io documentation built on May 5, 2024, 1:39 p.m.