Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R中的多个文本字符串修改_R_Text_Nlp - Fatal编程技术网

R中的多个文本字符串修改

R中的多个文本字符串修改,r,text,nlp,R,Text,Nlp,我在一个原子向量中存储了多个字符串: v <- c("The kat ran up the tree", "The dogg ran up the tree", "The squirrrel run up the tree") v最简单的选择是str\u replace\u all并传递一个名为的向量或列表 library(stringr) str_replace_all(v, setNames(v2, v1)) -输出 #[

我在一个原子向量中存储了多个字符串:

v <- c("The kat ran up the tree", "The dogg ran up the tree", "The squirrrel run up the tree")

v最简单的选择是
str\u replace\u all
并传递一个名为
向量或
列表

library(stringr)
str_replace_all(v, setNames(v2, v1))
-输出

#[1] "The cat ran up the tree"     
#[2] "The dog ran up the tree"  
#[3]    "The squirrel run up the tree"
library(stringr)
str_replace_all(v, setNames(v2, v1))
#[1] "The cat ran up the tree"     
#[2] "The dog ran up the tree"  
#[3]    "The squirrel run up the tree"