Description Usage Arguments Details Value Examples
View source: R/myBasicFunctions.R
Check if a variable which should contains a logical value exists and its content is logical
1 | checkLogicalValue(variableL, default = NA, isRequired = T)
|
variableL |
a string containing the name of the variable to check |
default |
the result if the |
isRequired |
a logical value indicating if the function should stop in case the values are not numeric, default is TRUE |
If isRequired is set to TRUE
and the content of variableL
is not valid, it will stop and execute an error.
The first value contained in variableL
if it is logical or the default value
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # the content is logical:
myLogicalValue <- TRUE
myCheckedLogicalValue <- checkLogicalValue("myLogicalValue")
myLogicalValue <- NA
myCheckedLogicalValue <- checkLogicalValue("myLogicalValue")
# my value is not logical:
myLogicalValue <- "T"
## Not run:
myCheckedLogicalValue <- checkLogicalValue("myLogicalValue")
## End(Not run)
# A variable which does not exists:
myCheckedLogicalValue <- checkLogicalValue("myImaginaryVariableWhichShouldNotExists",
isRequired = FALSE)
# A variable which does not exists but with default:
myCheckedLogicalValue <- checkLogicalValue("myImaginaryVariableWhichShouldNotExists",
default = TRUE, isRequired = FALSE)
# A variable which does not exists but is required:
## Not run:
myCheckedLogicalValue <- checkLogicalValue("myImaginaryVariableWhichShouldNotExists")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.