Skip to content

Instantly share code, notes, and snippets.

@zunman
Created August 5, 2016 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zunman/a96852bfc763cc85633526d7efa42226 to your computer and use it in GitHub Desktop.
Save zunman/a96852bfc763cc85633526d7efa42226 to your computer and use it in GitHub Desktop.
#Remove RTs and urls
CaseSensitive_FilterTerms <- c("RT", "http")
filter_regex<- paste(CaseSensitive_FilterTerms, collapse = "|")
df <- filter(df, !grepl(filter_regex, df$text))
#remove mentions. (only remove tweets that start with @)
df$noMentions <- 0 #add new temporary column
df$noMentions <- substr(c(df$text),0,1)
df <- filter(df, !grepl(c("@"), df$noMentions))
df$noMentions <- NULL #remove temporary column added in line7
write.csv(df, file = "files/tweets_noRtUrl_noMentions.csv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment