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"