Replace entire strings based on partial match
I'd suggest using grepl
to find the indices and replace those indices with "Red":
d = c("SDS0G2 Blue", "Blue SSC2CWA3", "Blue SA2M1GC", "SA5 Blue CSQ5", "ABCDE")
d[grepl("Blue", d, ignore.case=FALSE)] <- "Red"
d
# [1] "Red" "Red" "Red" "Red" "ABCDE"