提问人:Rastko M. 提问时间:5/21/2023 最后编辑:Rastko M. 更新时间:5/21/2023 访问量:33
筛选输出,使二元图必须包含特定单词
Filter the output so that bigram chart must contain specific words
问:
我在过滤我的二元图时遇到问题,以便它包含一个特定的单词。代码如下:
light_df$text %>%
unnest_tokens(word, text, token = "ngrams", n = 2) %>%
separate(word, c("word1", "word2"), sep = " ") %>%
filter(!word1 %in% stop_words$word) %>%
filter(!word2 %in% stop_words$word) %>%
unite(word, word1, word2, sep = " ") %>%
filter(word1 == "light" | word2 == "light") %>%
count(word, sort = TRUE) %>%
slice_max(n, n = 25) %>%
ggplot() +
geom_bar(aes(word, n), stat = "identity", fill = "#de5833") +
theme_minimal() +
coord_flip()
当我在添加过滤器之前这样做时,它运行良好。然后我只添加了过滤器功能,但是当我运行它时,出现了以下错误:
filter(., word1 == “light” | word2 == “light”) 中的错误: 由错误引起: !未找到对象“word1”
错误出在哪里?
答: 暂无答案
评论
unite
unite(..., remove = FALSE)