[R] Applying "toupper" to only portions of text strings
Dennis Fisher
fisher at plessthan.com
Fri May 27 00:05:01 CEST 2011
Colleagues
Assume that I have a vector containing some text strings, some of which contain a particular character. I could like to apply "toupper" to the text before the character. For example (in this case, "|" is the particular character):
ORIGINAL:
TEXT <- c("aaaa", "bbb|cc", "|ddd")
AFTER APPLICATION OF toupper:
TEXT <- c("AAAA", "BBB|cc", "|dddd")
I could loop through each element, strsplit at the character, apply toupper to the first component, then paste each element together. But, I hope that there is a simpler means to accomplish this.
Thanks in advance.
Dennis
Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.com
More information about the R-help
mailing list