system_file {svMisc} | R Documentation |
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 |
If |
package |
The name of one package to look for files or subdirs in its
main directory (use |
lib.loc |
A character vector with path names of R libraries or |
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()
).
Note
These function aggregate the features of several R functions in
package base: system.file()
, R.home()
, tempdir()
, Sys.which()
, and
aims to provide a unified and convenient single interface to all of them. We
make sure also to check that returned components are respectively directories
and files for system_dir()
and system_file()
.
See Also
file_edit()
, file.path()
, file.exists()
Examples
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")