Мы можем использовать startsWith
:
df$PlayerID[startsWith(df$PlayerID, 'MMM')] <- 'MMM'
Мы также можем использовать это в replace
:
df$PlayerID <- replace(df$PlayerID, startsWith(df$PlayerID, 'MMM'), 'MMM')
df
# PlayerID
#1 Hank_Aaron+7
#2 Babe Ruth+5
#3 MMM
#4 Willie Mayes+1
#5 MMM
data
df <- structure(list(PlayerID = c("Hank_Aaron+7", "Babe Ruth+5", "MMM + 7",
"Willie Mayes+1", "MMM + 3")), class = "data.frame", row.names = c(NA, -5L))