R - 整洁文本 unnest_token默认令牌参数是唯一有效的参数



整洁文本的新手并遇到错误。

当我尝试将"单词"以外的任何内容传递到 unnest_tokens 函数的令牌参数中时,我得到:

eval(substitute(expr(, envir, enclos( 中的错误:找不到对象 'txt'

甚至无法运行文档示例...

library(dplyr)
library(janeaustenr)
library(tidytext)
d <- data_frame(txt = prideprejudice)
d %>% unnest_tokens(word, txt, token = "words") #Works
d %>% unnest_tokens(sentence, txt, token = "sentences") #doesnt work
d %>% unnest_tokens(ngram, txt, token = "ngrams", n = 2) #doesnt work

当我在自己的代码(不是示例(上运行它时,我得到:

eval(substitute(expr(, envir, enclos( 中的错误:参数类型无效

我希望这是一种"面手掌"类型的错误:)。奇怪的是,我什至无法运行帮助示例...

谢谢!

我无法使用所有这些软件包的当前 CRAN 版本重现这些错误。

library(dplyr)
library(janeaustenr)
library(tidytext)
d <- data_frame(txt = prideprejudice)
d %>% unnest_tokens(word, txt, token = "words") 
#> # A tibble: 122,204 x 1
#>    word     
#>    <chr>    
#>  1 pride    
#>  2 and      
#>  3 prejudice
#>  4 by       
#>  5 jane     
#>  6 austen   
#>  7 chapter  
#>  8 1        
#>  9 it       
#> 10 is       
#> # ... with 122,194 more rows
d %>% unnest_tokens(sentence, txt, token = "sentences") 
#> # A tibble: 7,066 x 1
#>    sentence                                                               
#>    <chr>                                                                  
#>  1 pride and prejudice  by jane austen    chapter 1   it is a truth unive…
#>  2 however little known the feelings or views of such a man may be on his…
#>  3 ""my dear mr."                                                        
#>  4 "bennet," said his lady to him one day, "have you heard that netherf…
#>  5 mr.                                                                    
#>  6 bennet replied that he had not.                                        
#>  7 ""but it is," returned she; "for mrs."                              
#>  8 "long has just been here, and she told me all about it.""             
#>  9 mr.                                                                    
#> 10 bennet made no answer.                                                 
#> # ... with 7,056 more rows
d %>% unnest_tokens(ngram, txt, token = "ngrams", n = 2)
#> # A tibble: 122,203 x 1
#>    ngram         
#>    <chr>         
#>  1 pride and     
#>  2 and prejudice 
#>  3 prejudice by  
#>  4 by jane       
#>  5 jane austen   
#>  6 austen chapter
#>  7 chapter 1     
#>  8 1 it          
#>  9 it is         
#> 10 is a          
#> # ... with 122,193 more rows

创建于 2018-05-08 由 reprex 软件包 (v0.2.0(.

也许您应该尝试从 CRAN 重新安装这些软件包?

最新更新