Description Usage Arguments Details Value Examples
View source: R/myBasicFunctions.R
Check if a variable which should contains numerical values exists and all values are numeric
1 | checkNumericalValues(variableN, default = NA, isRequired = T)
|
variableN |
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 variableN
is not valid, it will stop and execute an error.
The content of variableN
if they are all numeric 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 | # all values are numeric:
myNumbers <- 1:3
myCheckedNumbers <- checkNumericalValues("myNumbers")
# some values are not numeric:
## Not run:
myNumbers <- list(1,2,"T")
myCheckedNumbers <- checkNumericalValues("myNumbers")
## End(Not run)
# A variable which does not exists:
myCheckedNumbers <- checkNumericalValues("myImaginaryVariableWhichShouldNotExists",
isRequired = FALSE)
# A variable which does not exists but with default:
myCheckedNumbers <- checkNumericalValues("myImaginaryVariableWhichShouldNotExists",
default = c(1,2,12), isRequired = FALSE)
# A variable which does not exists but is required:
## Not run:
myCheckedNumbers <- checkNumericalValues("myImaginaryVariableWhichShouldNotExists")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.