我正在尝试使用 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/