iofile: Get file names for data import/export

View source: R/iofile.R

iofileR Documentation

Get file names for data import/export

Description

Get file names for data import/export

Usage

iofile(x = NULL)

Arguments

x

File or directory name

Quite often we need to import and export data (especially bulky files) into a directory other than the local file. This function is a shortcut to get full names of import/export files.

The function first determines whether the option dataDir in the options of ribiosIO exists. If yes, its value will be used as the directory from/to which input/export files should be read/written.

If the value does not exist yet, the function tries to use a folder named data in the current working directory as dataDir. If this local folder exists, its name will be assigned to the dataDir option. If the folder does not exist, the function will report an error and quit.

The steps above guarantees that there is an option named dataDir, pointing to a directory where files are read from or written to.

The parameter x can be file or directory names in the dataDir directory. In this case, iofile(x) returns their full names. When x is missing or NULL, iofile() returns the value of dataDir. A common usage for the later case is dir(iofile()).

Value

Character string, the full path to the data directory (when x is NULL) or the full file path(s) within the data directory.

Examples

setDataDir(system.file("extdata", package="ribiosIO"))
dir(iofile())
readLines(iofile("test.gct"), n=2)

ribiosIO documentation built on Feb. 20, 2026, 5:09 p.m.