Title: | Explore Twitter Trends with the 'Storywrangler' API |
---|---|
Description: | An interface to explore trends in Twitter data using the 'Storywrangler' Application Programming Interface (API), which can be found here: <https://github.com/janeadams/storywrangler>. |
Authors: | Christopher Belanger [aut, cre] |
Maintainer: | Christopher Belanger <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.0 |
Built: | 2024-11-23 04:01:52 UTC |
Source: | https://github.com/chris31415926535/storywranglr |
Storywrangler's ngrams API lets you search a large historical database of Twitter data for daily usage statistics about strings of one, two, and three words (1-grams, 2-grams, and 3-grams respectively).
This function returns daily historical usage statistics for a given query over data set's entire time range.
For more details about Storywrangler, please see:
API documentation: https://github.com/janeadams/storywrangler
Academic paper describing uses: https://advances.sciencemag.org/content/7/29/eabe6534.full
ngrams( query, metric = c("rank", "freq"), language = "en", rt = c(FALSE, TRUE), fill_dates = FALSE )
ngrams( query, metric = c("rank", "freq"), language = "en", rt = c(FALSE, TRUE), fill_dates = FALSE )
query |
Character string with the n-gram(s) to query. One, two, or three words separated by spaces will run query that string as a 1-gram, 2-gram, or 3-gram respectively. More than three space-separated words will be treated as separate queries for individual 1-grams. |
metric |
The measure of lexical fame to return: accepts values |
language |
Two-letter code for the language to search. Defaults to |
rt |
Boolean for whether to include retweets. |
fill_dates |
Boolean, defaults to |
A tibble with the API query and response. If the API returns no data, this function returns a 0-row tibble.
## Not run: # Query a simple 1-gram about the populatity of potatoes result <- ngrams("potatoes") # Query a 2-gram about the popularity of potato chips result <- ngrams("potato chips") # Query *four* 1-grams related to potatoes # Note! If there are more than 3 words, they are all treated as 1-grams result <- ngrams("potato potahto spud taters") ## End(Not run)
## Not run: # Query a simple 1-gram about the populatity of potatoes result <- ngrams("potatoes") # Query a 2-gram about the popularity of potato chips result <- ngrams("potato chips") # Query *four* 1-grams related to potatoes # Note! If there are more than 3 words, they are all treated as 1-grams result <- ngrams("potato potahto spud taters") ## End(Not run)
Storywrangler's ngrams API lets you search a large historical database of Twitter data for daily usage statistics about strings of one, two, and three words (1-grams, 2-grams, and 3-grams respectively).
This function will query the API for a specific date to return the rank and frequency data for its top n ngrams. Please note that queries of over 1000 ngrams will take a long time to load.
For more details about Storywrangler, please see:
API documentation: https://github.com/janeadams/storywrangler
Academic paper describing uses: https://advances.sciencemag.org/content/7/29/eabe6534.full
zipf(date, max = 100, language = "en", ngrams = c(1, 2, 3))
zipf(date, max = 100, language = "en", ngrams = c(1, 2, 3))
date |
The date to query, in either character "YYYY-MM-DD" or Date format. |
max |
The maximum number of ngrams to return. Defaults to 100. |
language |
The two-letter code of the language to query. Defaults to "en". |
ngrams |
Integer specifying the type of n-grams to return. Accepts 1, 2, and 3, and defaults to 1. |
A tibble with the API query and response.
## Not run: # Get top English 2-grams for January 6, 2021 result <- zipf("2021-01-06", ngrams = 2) ## End(Not run)
## Not run: # Get top English 2-grams for January 6, 2021 result <- zipf("2021-01-06", ngrams = 2) ## End(Not run)