【发布时间】:2020-07-10 01:10:20
【问题描述】:
我有一个词向量,我想从另一个词向量中删除。我正在使用 mapply 和 gsub,但收到错误“更长的参数不是更短长度的倍数”。
sw_column <- c(stop_words$word)
head(sw_column)
[1] "a" "a's" "able" "about" "above" "according"
x <- c(amplification.words, deamplification.words, negation.words)
head(x)
[1] "acute" "acutely" "certain" "certainly" "colossal" "colossally"
stop_words_clean <- mapply(gsub, x, "", sw_column)
error message: longer argument not a multiple of length of shorter
我希望从 sw_column 中删除 x 中的所有单词。注意:不是x中的所有单词都出现在sw_column中
【问题讨论】:
-
您需要
sw_column[sw_column %in% x] <- ''吗? -
也许:
stop_words_clean <- setdiff(sw_column, x)。很难知道您的预期输出是什么样的。