регулярное выражение R Base:
words <- c("hello", "world")
# Last character of last word in vec element:
gsub("(\\w$)", "\\U\\1", words, perl = TRUE)
sentences <- c("hello world", "hello friend")
# Last character of sentence:
gsub("(\\w$)", "\\U\\1", sentences, perl = TRUE)
# Last character of each word in the sentence:
gsub("(\\w\\s+|\\w$)", "\\U\\1", sentences, perl = TRUE)