filter_tweets: Filter tweets

View source: R/filter_tweets.R

filter_tweetsR Documentation

Filter tweets

Description

Filter tweets by keywords.

Usage

filter_tweets(data, keywords, include = TRUE)

Arguments

data

Data frame containing tweets and hashtags. Works with any data frame, as long as there is a "text" column of type character string and a "hashtags" column with comma separated character vectors. Can be obtained either by using load_tweets on a json object returned by Twitter's API v1.1 or by using stream_in on any json file, as long as it has a "text" and "hashtags" field. If you are unsure about the requirements you may load the sample piece of data contained in the package by following the example in the the example section of this help page.

keywords

Character string of keywords for black- or whitelisting provided via a comma separated character string.

include

Logical. Indicate where to perform exclusive or inclusive filtering. Inclusive filtering is akin to whitelisting keywords. Exclusive filtering is blacklisting certain keywords.

Details

Use this function if you want your Tweets to contain certain keywords. This can be used for iterative filtering to create more coherent topic models. Keyword filtering is always case insensitive (lowercase).

Value

Data frame of Tweets containing specified keywords

Examples

## Not run: 

library(Twitmo)


# load tweets (included in package)
mytweets <- load_tweets(system.file("extdata", "tweets_20191027-141233.json", package = "Twitmo"))

# Exclude Tweets that mention "football" and/or "mood"
keyword_dict <- "football,mood"
mytweets_reduced <- filter_tweets(mytweets, keywords = keyword_dict, include = FALSE)

## End(Not run)


abuchmueller/Twitmo documentation built on Sept. 14, 2022, 8:06 p.m.