简体   繁体   English

删除R / Shiny中的疯狂角色

[英]Remove Crazy Characters in R/Shiny

I have a long list in the format like such: 我有一长串这样的格式:

group1 » group2 » group3

Within R, I can use a gsub('»', '-', x) where x is the vector structured like above. 在R中,我可以使用gsub('»', '-', x) ,其中x是如上所述的向量结构。

However, I am running into errors when trying to utilize this functionality when loading this into a shiny app. 但是,将其加载到闪亮的应用程序时尝试使用此功能时遇到错误。 I've tried multiple ways to use gsub , chartr , and some other ones. 我尝试了多种使用gsubchartr和其他方法的方法。

Also, The  character is not captured when using [[:punct:]] . 另外,使用[[:punct:]]时不会捕获Â字符。

Any suggestions? 有什么建议么?

group1 » group2 » group3 is a UTF-8 encoded string and therefore it would be best if the R application is coded to read the strings with conversion from UTF-8 to Latin 1 as explained on Read or Set the Declared Encodings for a Character Vector and Read text as UTF-8 encoding . group1 » group2 » group3UTF-8编码的字符串,因此最好将R应用程序编码为按从UTF-8到Latin 1的转换来读取字符串,如“ 读取或设置声明的编码”中所述。字符向量读取文本为UTF-8编码

» is the UTF-8 encoded right-pointing double angle quotation mark whereby the 2 bytes with the hexadecimal values C2 BB are interpreted and displayed (wrong) with code page Windows-1252 or ISO 8859-1 (Latin-1). »是UTF-8编码的右指向双角引号 ,其中带有十六进制值C2 BB的2个字节在代码页Windows-1252ISO 8859-1 (Latin-1)中被解释和显示(错误)。

gsub("\\\\xC2?\\\\xBB", "-", x) could be used to find in a UTF-8 encoded string or single byte encoded string (Latin 1 or Windows 1252) all right pointing guillemets and replace each of them by a hyphen character. gsub("\\\\xC2?\\\\xBB", "-", x)可用于在UTF-8编码的字符串或单字节编码的字符串(拉丁语1或Windows 1252)中找到所有正确指向的guillemet,并替换每个它们由连字符组成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM