r - 找不到函数 "unnest_tokens"

标签 r tidytext unnest

我正在尝试使用 tokenizers 包将一列拆分为 token ,但我一直收到错误:找不到函数“unnest_tokens”。我正在使用 R 3.5.3,并且已经安装并重新安装了 dplyr、tidytext、tidyverse、tokenizers、tidyr,但仍然收到错误消息。

我也退出并重新启动了 R 和 RStudio。

comments_tidy <- comments %>%
  unnest_tokens(word, txt) %>% #Break the comments into individual words
  filter(!word %in% undesirable_words) %>% #Remove undesirables
  anti_join(stop_words) #Data provided by the tidytext package

我收到以下信息:

Error in unnest_tokens(., word, txt) :
could not find function "unnest_tokens"

最佳答案

如评论中所述,您可能希望使用 library(x) 扩展您的代码。声明。另外,确保所有的包及其依赖项 已安装。以下代码段将查找给定的包(在本例中为 dplyr )并在需要时安装它。

if ("dplyr" %in% installed.packages()[, "Package"]){ 
  cat("'dplyr' is installed.")
} else {
  install.packages("dplyr",dependencies=T)
}
library(dplyr)
命令 installed.packages()[, "Package"])?为您提供所有已安装软件包的列表,这是调试所有类型的好技巧 Function foo not found错误。

关于r - 找不到函数 "unnest_tokens",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55766153/

相关文章:

r - 用 R 中指定单词旁边的单词过滤所有行

sql - 展平 BigQuery 表中多个相同大小的数组列

r - 使用 `texreg` 根据回归模型中出现的顺序显示变量名称

R图: Print text on margin in top left corner

r - 使用 unnest_tokens() 按特定字符拆分列?

r - 将组合变量 (combn) 作为向量解除嵌套

sql - 从数组创建字符串

r - 使用ggplot boxplot进行位置躲避警告?

r - 使用 eulerr R 自定义欧拉图颜色

R tidytext stop_words 没有从 gutenbergr 下载中一致地过滤