![]() |
VOOZH | about |
In R Programming Language, we can use the if-else statement to check if a character string contains a specific substring. The if-else statement allows us to execute different code blocks based on a certain condition, in this case, whether the substring is present in the given string.
The if-else statement is a control structure in R used to make decisions based on a given condition.
The if-else statement is a control structure in R used to make decisions based on a given condition.
A substring is a smaller sequence of characters that appears within a larger character string.
To check if a character string contains a specific substring, follow these steps:
Let's consider a few examples to illustrate how to use the if-else statement in R to check for a specific substring.
Output:
[1] "The string contains 'apple'."
Output:
[1] "The string does not contain 'mango'."