0

在这本书关于 tydy-text 之后获得 n-gram:http: //tidytextmining.com/ngrams.html

编码:

library(tidyr)

bigrams_separated <- austen_bigrams %>%
  separate(bigram, c("word1", "word2"), sep = " ")

bigrams_filtered <- bigrams_separated %>%
  filter(!word1 %in% stop_words$word) %>%
  filter(!word2 %in% stop_words$word)

# new bigram counts:
bigram_counts <- bigrams_filtered %>% 
  count(word1, word2, sort = TRUE)

我收到一个错误:

Warning: Error in : 'sep' is not an exported object from 'namespace:dplyr'
4

2 回答 2

0

试试这个不加载 tidyr 的代码:

bigrams_separated <- austen_bigrams %>%
mutate(word1 = sub(" .*", "", bigram),
       word2 = sub(".* ", "", bigram))
于 2017-11-07T15:11:14.300 回答
0

我遇到了一个相同的错误,似乎可以通过指定 tidyr::separate() 来解决

于 2019-07-01T15:07:04.300 回答