如何随机gsub文本

时间:2018-03-11 14:22:08

标签: r

我正在尝试创建一些文本。我有一个数据框如下(其中有更多的文本行)

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

如何将随机替换的概念引入gsubstr_replace

1 个答案:

答案 0 :(得分:3)

我们可以获得substr_replace()可能的值来替换,然后进行替换

sample