Description Usage Arguments Details Value Examples
View source: R/myBasicFunctions.R
Check if a variable which should contains a path for a file exists and has a value which corresponds to an existing file
1 |
variableFile |
a string containing the name of the variable to check |
default |
the result if the variableFile is not assigned or the file does not exists and isRequired is set to FALSE, default is NA |
isRequired |
a logical value indicating if the function should stop in case the file does not exists, default is TRUE |
If isRequired is set to TRUE
and the content of variableFile
is not valid, it will stop and execute an error.
The content of variableFile
if it is the path to an existing file or the default value
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # A file which exists:
myFile <- ".Rhistory"
myFile <- list.files()[1]
myCheckedFile <- checkFile("myFile")
# A variable which does not exists:
myCheckedFile <- checkFile("myImaginaryVariableWhichShouldNotExists",isRequired=FALSE)
# A variable which does not exists but with default:
myCheckedFile <- checkFile("myImaginaryVariableWhichShouldNotExists",
default=".Rhistory", isRequired=FALSE)
# A variable which does not exists but is required:
## Not run:
myCheckedFile <- checkFile("myImaginaryVariableWhichShouldNotExists")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.