I need to convert certain words to lowercase. I work with a list of movie titles, where prepositions and articles are usually lowercase unless they are the first word in the title. If I have a vector:
movies = c('The Kings Of Summer', 'The Words', 'Out Of The Furnace', 'Me And Earl And The Dying Girl')
I need this:
movies_updated = c('The Kings of Summer', 'The Words', 'Out of the Furnace', 'Me and Earl and the Dying Girl')
Is there an elegant way to do this without using the long gsub() series, as in:
movies_updated = gsub(' In ', ' in ', movies) movies_updated = gsub(' In', ' in', movies_updated) movies_updated = gsub(' Of ', ' of ', movies) movies_updated = gsub(' Of', ' of', movies_updated) movies_updated = gsub(' The ', ' the ', movies) movies_updated = gsub(' the', ' the', movies_updated)
And so on.
source share