Given a lower case string. Ex:
s <- 'abcdefghijklmnopqrstuvwxyz'
The goal is to make every other vowel in the string an uppercase.
Desired output here:
abcdEfghijklmnOpqrstuvwxyz
As you can see, since all vowels where used in order, e
and o
where uppercase.
There are only lowercase characters in the strings in all cases.
For aieou
, the desired output is:
aIeOu
How could I do this in R?
I tried:
s[unlist(strsplit(s, '')) %in% c('a', 'e', 'i', 'o', 'u')] <- toupper(s[unlist(strsplit(s, '')) %in% c('a', 'e', 'i', 'o', 'u')])
But no avail.
Even if this worked, it wouldn't be every other vowel
R version 4.1.1.