我有一个带有如下角色变量的数据集,我想从该变量中删除一些单词。
我的数据:
<VirtualHost *:80>
...
ServerName BBB
...
</VirtualHost>
我想删除变量中的一些单词和字母。
预期结果:
variable
1 "star war it ik ar"
2 "jammu kashmir DO"
3 "hey Ho dude"
4 "time kya hi abhi"
5 "every one ji"
6 "thanks to iF everyone"
7 "hey i am in america yo"
我尝试了以下内容:
variable created_var
1 "star war it ik ar" "star war"
2 "jammu kashmir DO" "jammu kashmir"
3 "hey Ho dude" "hey dude"
4 "time kya hi abhi" "time kya abhi"
5 "every one ji" "every one"
6 "thanks to iF everyone" "thanks to everyone"
7 "hey i am in america yo" "hey i am in america"
上面的代码适用于单个单词,但不适用于单词组。如何删除waste <- c("it", "ik", "ar", "DO", "Ho", "hi", "iF", "yo")
data$created_var <- gsub(waste, "", data$variable)
中的所有字词?