Replace values in R column without impacting words with the same characters

I am trying to replace the characters ST with Street, without impacting other values within the column, such as the word Stretch. I have found that the methods attempted so far do not change to ST when it is at the end of the string, such as: 100 60TH AVE & 96TH ST or I get something like "203 StreetREET" where Street has replaced ST on words that are currently STREET. I have tried to use

str_replace(oil_one$Facility, c("ST"), "Street")


oil_one$Facility[oil_one$Facility== "ST"] <- "Street"

Could somebody please demonstrate how to correctly do this on the column of a data frame?

Read more here:

Content Attribution

This content was originally published by user15515862 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: