【发布时间】:2020-10-14 21:34:21
【问题描述】:
我需要从文本中删除停用词而不将对象标记或更改为列表。使用 rm_stopwords 函数时出现错误。谁能帮帮我?
test<- data.frame(words = c("hello there, everyone", "the most amazing planet"), id = 1:2)
test$words <- rm_stopwords(test$words, tm::stopwords("english"), separate = F, unlist = T)
#Error in `$<-.data.frame`(`*tmp*`, words, value = c("hello", "everyone", :
#replacement has 4 rows, data has 2
#I want something like this, where the stopwords are removed but the rest of the formatting remains intact (e.g. punctuation)
# words id
#1 hello , everyone 1
#2 amazing planet 2
【问题讨论】:
标签: r text tidyverse tidyr stop-words