我在使用tidytext和dplyr库的旧脚本上遇到了问题。
我的示例摘自:https://community.rstudio.com/t/problem-with-unnest-tokens-function/94107
但我也有同样的问题:
library(gutenbergr)
library(dplyr)
library(tidytext)
TTLutS_.ted <- gutenberg_download(164, mirror = "http://mirrors.xmission.com/gutenberg/")
Ulysses_.ted <- gutenberg_download(4300, mirror = "http://mirrors.xmission.com/gutenberg/")
TTLutS <- tibble(TTLutS_.ted)
Ulysses <- tibble(Ulysses_.ted)
TTLutS.words <- TTLutS %>% unnest_tokens(word, text)
Ulysses.words <- Ulysses %>% unnest_tokens(word, text)
TTLutS.words %>% count(word, sort = TRUE)错误: objeto 'txt‘no encontrado运行rlang::last_error()查看错误发生的位置。
count(.,word,sort = TRUE)出错:未使用的参数(sort = TRUE)
发布于 2021-11-01 22:16:51
最后我找到了一个简单的解决方案
library(gutenbergr)
library(dplyr)
library(tidytext)
TTLutS_.ted <- gutenberg_download(164, mirror = "http://mirrors.xmission.com/gutenberg/")
Ulysses_.ted <- gutenberg_download(4300, mirror = "http://mirrors.xmission.com/gutenberg/")
TTLutS <- tibble(TTLutS_.ted)
Ulysses <- tibble(Ulysses_.ted)
TTLutS.words <- TTLutS %>% unnest_tokens(word, text)
Ulysses.words <- Ulysses %>% unnest_tokens(word, text)
TTLutS.words %>% mutate(n = str_count(word))https://stackoverflow.com/questions/69803203
复制相似问题