Learn R Programming

svMisc (version 1.1.0)

system_file: Get a system file or directory

Description

Get system files or directories, in R subdirectories, in package subdirectories, or elsewhere on the disk (including executables that are accessible on the search path).

Usage

system_file(..., exec = FALSE, package = NULL, lib.loc = NULL)

system_dir(..., exec = FALSE, package = NULL, lib.loc = NULL)

systemFile(..., exec = FALSE, package = NULL, lib.loc = NULL)

systemDir(..., exec = FALSE, package = NULL, lib.loc = NULL)

Arguments

...

One or several executables if exec = TRUE, or subpath to a file or dir in a package directory if package != NULL, or a list of paths and subpaths for testing the existence of a file on disk, or a list of directory components to retrieve in 'temp', 'sysTemp', 'user', 'home', 'bin', 'doc', 'etc' and/or 'share' to retrieve special system directories.

exec

If TRUE (default) search for executables on the search path. It superseedes all other arguments.

package

The name of one package to look for files or subdirs in its main directory (use exec = FALSE to search inside package dirs).

lib.loc

A character vector with path names of R libraries or NULL (search all currently known libraries in this case).

Value

A string with the path to the directories or files, or "" if they are not found, or of the wrong type (a dir for system_file() or or a file for system_dir()).

See Also

file_edit(), file.path(), file.exists()

Examples

Run this code
# NOT RUN {
system_file("INDEX", package = "base")
system_file("help", "AnIndex", package = "splines")
system_file(package = "base")  # This is a dir, not a file!
system_file("zip", exec = TRUE)
system_file("ftp", "ping", "zip", "nonexistingexe", exec = TRUE)
system_dir("temp")             # The R temporary directory
system_dir("sysTemp")          # The system temporary directory
system_dir("user")             # The user directory
system_dir("home", "bin", "doc", "etc", "share")  # Various R dirs
system_dir("zip", exec = TRUE) # Look for the dir of an executable
system_dir("ftp", "ping", "zip", "nonexistingexe", exec = TRUE)
system_dir(package = "base")   # The root of the 'base' package
system_dir(package = "stats")  # The root of package 'stats'
system_dir("INDEX", package = "stats") # This is a file, not a dir!
system_dir("help", package = "splines")
# }

Run the code above in your browser using DataLab