我有一个短语字符串向量,如下所示。
x <- c("I ate apples 100 already. No apples 50 uhmm" , "He has apples 20 yeah")
And I expect the result to be:
"I ate 100 apples already. No 50 apples uhmm" , "He has 20 apples yeah"
我希望能够在向量的每个元素中将以下模式
"apples \\d{1,4}"
替换为找到的单词的反向顺序。 有什么建议吗?