String 从R中的字符串中删除某些字符

String 从R中的字符串中删除某些字符,string,r,String,R,我在R中有一个字符串,其中包含大量单词。查看字符串时,我会得到大量文本,其中包含类似以下内容的文本: >docs .... \u009cYes yes for ever for ever the boys cried in their ringing voices with softened faces .... 因此,我想知道如何从字符串中删除这些\u009字符(所有字符,其中一些数字略有不同)。我尝试过使用gsub(),但在从字符串中删除内容时无效。这应该行得通 gsub('\

我在R中有一个字符串,其中包含大量单词。查看字符串时,我会得到大量文本,其中包含类似以下内容的文本:

>docs

....

\u009cYes yes for ever for ever the boys cried in their ringing voices with softened faces

....
因此,我想知道如何从字符串中删除这些\u009字符(所有字符,其中一些数字略有不同)。我尝试过使用
gsub()
,但在从字符串中删除内容时无效。

这应该行得通

gsub('\u009c','','\u009cYes yes for ever for ever the boys ')
"Yes yes for ever for ever the boys "
这里009c是unicode的十六进制数。必须始终指定4个十六进制数字。 如果有多个,一种解决方案是用管道将它们分开:

gsub('\u009c|\u00F0','','\u009cYes yes \u00F0for ever for ever the boys and the girls')

"Yes yes for ever for ever the boys and the girls"
尝试:
gsub(“\\$”、“,$5.00$”)

关于“必须始终指定4位数字”:这仅在执行unicode时适用。这应该可以很好地删除空格和破折号:
gsub(“|-”,“'1-444-654')
我想知道,是否有一个函数类似于Excel的right()或left()?尽可能简单,但不简单。完美的