Description Usage Arguments Details Value Examples
Searches for file in the sequence of data repositories
specified as strings in the variable datapath. Returns the path to file as
a string tipically for use in input functions (read.table, etc...)
1 |
file |
String. The name of the file to search for in the data repositories. |
literal |
A logical scalar. Should the file be searched in the data
repositories or just locally? If TRUE, just returns |
datafile searches for file
first in the first component of the vector datapath. If it finds it, it returns the
concatenation of datapath[1] and file. If it does not, it looks for
file in the second component of datapath, returns the concatenation of
datapath[2] and file. If literal = TRUE,
it just returns file without checking whether file exists in the current directory. If file is not found in any of the directories
specified in datapath and literal = FALSE, a message error is thrown
and the execution is stopped.
The path to the datarepositories in datapath should end with "/".
For example datapath <- "~/OPADA/data/".
The output is a string that contains the path to file in one of
the data repository specified in datapath. If literal = TRUE,
it just returns file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ## defines two data repositories
datapath <- c("~/OPADA/data/", "./data/)
\dontrun
{
datafile("mydata.txt")
}
## In the case when "mydata.txt" is not found in "~OPADA/data/" but is located
## in "./data/":
## > "./data/mydata.txt
## In the case when "mydata.txt" is not to be found in any of the datadirectories
## specified in \code{datapath}
## Error in datafile("brout") :
## Unable to find file brout in any of the folders specified by datapath.
## With \code{literal = TRUE}, returns the argument \code{file} without checking
## whether it exists.
datafile("mydata.txt", literal = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.