Description Usage Arguments Details Value Examples
View source: R/myBasicFunctions.R
Check if a variable which should contains strings values exists and return values overlapping with the possible
1 | checkStrings(variableS, possible = NA, default = NA, isRequired = T)
|
variableS |
a string containing the name of the variable to check. |
possible |
a vector containing the accepted string values or NA if there is no constrain. Default is NA. |
default |
the result if the |
isRequired |
a logical value indicating if the function should stop in case no value overlap with |
If isRequired is set to TRUE and the content of variableS is not valid, it will stop and execute an error.
The content of variableS if they are all included in possible (if possible is not NA)
Or the overlap between its content and possible (if possible is not NA).
Or the default value
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | myStrings <- c("one", "two", "three")
# No restriction
myCheckedStrings <- checkStrings("myStrings")
# Restriction which match
myCheckedStrings <- checkStrings("myStrings", possible = c("one", "two", "three", "four"))
# Restriction which match partially
myCheckedStrings <- checkStrings("myStrings", possible = c("one", "two"))
# Restriction which does not match
## Not run:
myCheckedStrings <- checkStrings("myStrings", possible = c("One", "Two"))
## End(Not run)
# A variable which does not exists:
myCheckedStrings <- checkStrings("myImaginaryVariableWhichShouldNotExists", isRequired = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.