Learn R Programming

svMisc (version 0.9-60)

systemFile: 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

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 path and subpaths for testing the existence of a file on disk, or a list of directory compone
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 Rlibraries 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 systemFile() or or a file for systemDir()).

concept

system files and directories

See Also

file.path, file.exists

Examples

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

Run the code above in your browser using DataLab