0

我目前正在尝试在 R 中使用我第一次使用它时有效的脚本来获取 wordcloud。我现在正在重新检查我的降价文档并遇到以下问题。

我正在rtweet为特定主题的大量推文创建一个 wordcloud。

tokenized_tweets <- tidy_tweets %>% select(status_id, text) %>% unnest_tokens(word, text)

custom_stopwords <- tibble(lexicon = "custom", word = c("t.co", "https"))

tokenized_tweets %>%
  anti_join(stop_words) %>%
  anti_join(custom_stopwords) %>%
  count(word) %>%
  with(wordcloud(word, n, max.words = 25))

但是,当我使用此脚本(对我有用)时,我得到以下输出:

Joining, by = "word"Joining, by = "word"Error in UseMethod("as.quoted") : no applicable method for 'as.quoted'应用于类“function”的对象

谢谢您的帮助!

4

1 回答 1

0

为了便于参考,请在下面找到一个使用reprex. 一切正常,它应该在一个干净的 R 会话中为您工作(重新启动 R,删除所有对象,然后重新运行您的代码)。

查看您的错误消息,您的工作区中似乎有一个custom_stopwords函数......考虑为您调用的数据框提供任何其他名称custom_stopwords

library("rtweet")
library("tidytext")
library("tibble")
library("dplyr")
library("wordcloud")

tidy_tweets <- rtweet::search_tweets(q = "punk") 

tokenized_tweets <- tidy_tweets %>% select(status_id, text) %>%
  unnest_tokens(word, text)

custom_stopwords <- tibble(lexicon = "custom", word = c("t.co", "https"))

tokenized_tweets %>%
  anti_join(tidytext::stop_words) %>%
  anti_join(custom_stopwords) %>%
  count(word) %>%
  with(wordcloud(word, n, max.words = 25))
#> Joining, by = "word"
#> Joining, by = "word"

reprex 包(v0.3.0)于 2020-01-12 创建

于 2020-01-12T16:55:43.980 回答