我正在尝试创建一些文本。我有一个数据框如下(其中有更多的文本行)
out<-data.frame(c("The road it long. It has many a winding path","The rain clouds are coming","My aunt has blue hair. It is like Marj Simpson's hair","The oesophagus is long. It is like a toothpaste tube"))
我想替换它。&#39;它。&#39;用&#39;和&#39;但我想随机这样做,以便输出示例:
The road it long and has many a winding path
The rain clouds are coming
My aunt has blue hair. It is like Marj Simpson's hair
The oesophagus is long and is like a toothpaste tube
如何将随机替换的概念引入gsub
或str_replace
?
答案 0 :(得分:3)
我们可以获得substr_replace()
可能的值来替换,然后进行替换
sample