Case-sensitive comparison
In this example we have compare two string in case sensitive.
R
# Define two strings(str1 and str2) String_1 <- "w3wiki" String_2 <- "w3wiki" # Conditional if statement to check whether string are equal or not if (String_1 == String_2) { cat ( "The strings are equal" ) } else { cat ( "The strings are not equal" ) } |
Output:
The strings are not equal
- Since the case are not equal for both the strings, so output is false i.e. “The strings are not equal”.
Program to Compare two Strings in R
String comparison is a common operation where two strings are compared in a case sensitive manner and check whether they are equal or not. In this article you will learn the various way in which you can compare two string in R language.
Contact Us