## Simple example
startsWith("Testing", "Test")
## Vector examples
s <- c("Testing", " Testing", "testing", "Texting")
names(s) <- s
startsWith(s, "Test") # " Testing", "testing", and "Texting" do not match
startsWith(s, "Test", trim=TRUE) # Now " Testing" matches
startsWith(s, "Test", ignore.case=TRUE) # Now "testing" matches
# Comparison
# gdata
startsWith(s, "Test", trim=TRUE)
startsWith(s, "Test", ignore.case=TRUE)
# base
startsWith(trimws(s), "Test")
startsWith(tolower(s), tolower("Test"))
Run the code above in your browser using DataLab