📜  R clean tweets 中的 twitter 分析 - 无论代码示例

📅  最后修改于: 2022-03-11 14:55:44.344000             🧑  作者: Mango

代码示例9
library(tidyverse)    

    clean_tweets <- function(x) {
                x %>%
                        str_remove_all(" ?(f|ht)(tp)(s?)(://)(.*)[.|/](.*)") %>%
                        str_replace_all("&", "and") %>%
                        str_remove_all("[[:punct:]]") %>%
                        str_remove_all("^RT:? ") %>%
                        str_remove_all("@[[:alnum:]]+") %>%
                        str_remove_all("#[[:alnum:]]+") %>%
                        str_replace_all("\\\n", " ") %>%
                        str_to_lower() %>%
                        str_trim("both")
        }

    tweets %>% clean_tweets