【问题标题】:could not find function "unnest_tokens"找不到函数“unnest_tokens”
【发布时间】:2019-09-09 23:29:48
【问题描述】:

我正在尝试使用 tokenizers 包将一列拆分为标记,但我一直收到错误消息:找不到函数“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

我收到以下信息:

unnest_tokens(., word, txt) 中的错误:
找不到函数“unnest_tokens”

【问题讨论】:

  • 你打电话给library(x);library(y)了吗?
  • 是的,我为描述中提到的包调用了每个库。
  • 尝试明确:tidytext::unnest_tokens()
  • 谢谢!显式函数也帮助了我。

标签: r tidytext unnest


【解决方案1】:

如 cmets 中所述,您可能希望使用 library(x) 语句扩展您的代码。此外,请确保已安装所有软件包及其依赖项。下面的 sn-p 将查找给定的包(在本例中为 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 错误的好方法。

【讨论】:

    猜你喜欢
    • 2018-12-07
    • 2018-02-01
    • 2022-10-05
    • 2012-01-07
    • 2019-05-19
    • 2020-10-02
    • 2015-11-26
    • 2017-04-25
    • 2013-10-28
    相关资源
    最近更新 更多