用 gsub 替换带有重音符号的多个字母 [英] Replace multiple letters with accents with gsub
本文介绍了用 gsub 替换带有重音符号的多个字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
of course I could replace specific arguments like this:
mydata=c("á","é","ó")
mydata=gsub("á","a",mydata)
mydata=gsub("é","e",mydata)
mydata=gsub("ó","o",mydata)
mydata
but surely there is a easier way to do this all in onle line, right? I dont find the gsub help to be very comprehensive on this.
解决方案
Use the character translation function
chartr("áéó", "aeo", mydata)
这篇关于用 gsub 替换带有重音符号的多个字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文