Description Usage Arguments Details Value Examples
View source: R/myBasicFunctions.R
Check if a variable which should contains a path for a directory exists and has a value which corresponds to an existing folder
1 | checkDirectory(variableDirectory, default = NA, isRequired = T)
|
variableDirectory |
a string containing the name of the variable to check |
default |
the result if the variableDirectory is not assigned or the directory 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 folder does not exists, default is TRUE |
If isRequired is set to TRUE
and the content of variableDirectory
is not valid, it will stop and execute an error.
The content of variableDirectory
if it is the path to an existing directory or the default value
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # A directory which exists:
myDirectory <- "./"
myCheckedDirectory <- checkDirectory("myDirectory")
# A variable which does not exists:
myCheckedDirectory <- checkDirectory("myImaginaryVariableWhichShouldNotExists",isRequired=FALSE)
# A variable which does not exists but with default:
myCheckedDirectory <- checkDirectory("myImaginaryVariableWhichShouldNotExists",
default="./", isRequired=FALSE)
# A variable which does not exists but is required:
## Not run:
myCheckedDirectory <- checkDirectory("myImaginaryVariableWhichShouldNotExists")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.