checkDirectory: Check if a variable which should contains a path for a...

Description Usage Arguments Details Value Examples

View source: R/myBasicFunctions.R

Description

Check if a variable which should contains a path for a directory exists and has a value which corresponds to an existing folder

Usage

1
checkDirectory(variableDirectory, default = NA, isRequired = T)

Arguments

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

Details

If isRequired is set to TRUE and the content of variableDirectory is not valid, it will stop and execute an error.

Value

The content of variableDirectory if it is the path to an existing directory or the default value

Examples

 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)

lldelisle/usefulLDfunctions documentation built on Nov. 29, 2021, 5:40 a.m.