#Search for substring in a stringy <-c("carrot", "apple", "banana", "carrot")grep("carrot", y)#Replace a single value within a stringsub("r”, “R”, y)#Replace all instances within a stringgsub(“r”, “R”, y)#Find matches of exact stringsgrepl("car", y)
Outputs:
#Search for value in a string14#Returns the position of the value searched for#Replace the first instance of a single value within a string"caRrot""apple""banana""caRrot"#Replace all instances within a string"caRRot""apple""banana""caRRot"#Find matches of exact stringsTRUEFALSEFALSETRUE