count_stories: Count stories and tags

Description Usage Arguments Value Examples

View source: R/stories.R

Description

Search for stories with various parameters. Multiple parameters will be connected with AND in the call. count_stories gets the total number of stories, possibly by date. count_tags gets the total number of stories by tags.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
count_stories(
  text = NULL,
  title = NULL,
  media_id = NULL,
  after_date = NULL,
  before_date = NULL,
  split = TRUE,
  split_period = "day",
  key = NULL,
  tibble = TRUE
)

count_tags(
  text = NULL,
  title = NULL,
  media_id = NULL,
  after_date = NULL,
  before_date = NULL,
  n = 1000,
  tag_sets_id = NULL,
  key = NULL,
  tibble = TRUE
)

Arguments

text

Optional character vector for full text search passed to the Solr query. If character vector contains more than one element, elements will be connected with OR.

title

Optional character vector for title search passed to the Solr query. If character vector contains more than one element, elements will be connected with OR.

media_id

Optional media ids (see search_media) passed to the Solr query. If vector contains more than one element, elements will be connected with OR.

after_date

Limit results to stories published after this date. Should be a date string that can be interpreted as a POSIXct object, e.g., '2021-01-01' or '2021-12-24 09:00:00'. Note that '00:00:00' will be added if only passing a date.

before_date

Limit results to stories published before this date. Should be a date string that can be interpreted as a POSIXct object, e.g., '2021-01-01' or '2021-12-24 09:00:00'. Note that '00:00:00' will be added if only passing a date.

split

logical, either or not to split the count by split_period, default to TRUE

split_period

character, split the couny by this granularity, possible values are "day", "week", "month", and "year"

key

MediaCloud API key. Will be read from environment variable 'MEDIACLOUD_API_KEY' if set to NULL (default).

tibble

Logical indicating whether result should be returned as a tibble. Default to TRUE. If set to FALSE, the unedited content of the HTTP response will be returned instead.

n

numeric, maximum number of tags to return

tag_sets_id

character, if not NULL, only tags belonging to this tag sets is returned. For example, the tag set id of "2389" is tag set of people as identified by the CLIFF named-entity annotator.

Value

depending on the parameter tibble, the return object can be a tibble (tibble is TRUE) or a list (tibble is FALSE).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Not run: 
## search for daily count of articles mentioning "klimawandel" in German media
de_media <- search_media(tag = "Germany___National")
res_kw <- count_stories(text = "klimawandel", after_date = "2021-01-01",
before_date = "2021-12-22", media_id = de_media$media_id,
split = TRUE, split_period = "day")
## search for popular named entities in articles mentioning "covid" in German media
count_tags(text = "covid", media_id = de_media$media_id, n = 100,
after_date = "2020-01-01", tag_sets_id = "2389")

## End(Not run)

joon-e/mediacloud documentation built on Jan. 8, 2022, 12:04 a.m.