Register and dispatch file writers
Usage
registerWriter(format, fn, ext = NULL, overwrite = FALSE)
getWriter(format)
availableWriters()
unregisterWriter(format)Arguments
- format
Case-insensitive format key (e.g.
"brainvision").- fn
The writer function; its first arguments should be the object to write and a file path.
- ext
Optional character vector of file extensions handled (no dot).
- overwrite
If
FALSE(default), registering an existingformaterrors;TRUEreplaces it (use this in a package.onLoad).
Value
registerWriter() invisibly returns fn; getWriter() returns the
registered function; availableWriters() returns a data.frame of
format/ext (the format column holds normalized, lower-cased keys, and
the frame has zero rows when nothing is registered); unregisterWriter()
invisibly returns TRUE if a writer was removed.
See also
Other plugin-api:
physio-registry,
registerOperation(),
registerReader()
Examples
registerWriter("demo_csv", function(x, file, ...) write.csv(x, file, ...),
ext = "csv", overwrite = TRUE)
availableWriters()
#> format ext
#> 1 demo_csv csv
unregisterWriter("demo_csv")