尝试重现http://tidytextmining.com/twitter.html中的示例时出现问题。tidytext示例使用管道过滤器错误
基本上我想,以保持stop_Word代码
library(tidytext)
library(stringr)
reg <- "([^A-Za-z_\\d#@']|'(?![A-Za-z_\\d#@]))"
tidy_tweets <- tweets %>%
mutate(text = str_replace_all(text, "https://t.co/[A-Za-z\\d]+|http://[A-Za-z\\d]+|&|<|>|RT", "")) %>%
unnest_tokens(word, text, token = "regex", pattern = reg) %>%
filter(!word %in% stop_words$word,
str_detect(word, "[a-z]"))
,这部分包括适应的tweets数据帧。
所以我想这:
tidy_tweets <- tweets %>%
mutate(text = str_replace_all(text, "https://t.co/[A-Za-z\\d]+|http://[A-Za-z\\d]+|&|<|>|RT", "")) %>%
unnest_tokens(word, text, token = "regex", pattern = reg)
tidy_tweets_sw <- filter(!word %in% stop_words$word, str_detect(tidy_tweets, "[a-z]"))
但没有奏效,因为我得到了以下错误消息:
Error in match(x, table, nomatch = 0L) :
'match' requires vector arguments
我曾试图通过的两个输入向量版本匹配,但无济于事。 有没有人有更好的主意?
tidytext通常采用' anti_join(stop_words)'在小插曲中。 – alistaire