searchArticles: Search NY Times articles

searchArticlesR Documentation

Search NY Times articles

Description

This allows one to search NY Times articles from 1981 to the present day, looking for particular text. One can also specify a range of dates.

Usage

searchArticles(query, begin_date = NA, end_date = NA, ..., key = getOption("NYTimesAPI")["Article Search"],
                fields = character(), facets = character())

Arguments

query

the phrases to search for. This can be a character vector which is collapsed with white space.

begin_date,end_date

optional start and end dates, given as strings of the form "YYYYMMDD"

...

additional name = value parameters passed in the form query

key

a string giving the NY Times API key for the Article Search service

fields

character vector giving the names of the fields to return.

facets

character vector specifying up to 5 facets

Value

A list with an element for each element of the result set. Each element is a list with a body, byline, date, title and url field unless the caller specifies a value for fields.

Author(s)

Duncan Temple Lang

References

http://developer.nytimes.com/docs/times_newswire_api

Examples

if("NYTimesAPI" %in% names(options()) && "Article Search" %in% names(options("NYTimes")))  {
  searchArticles("title:bailout", begin_date = "20081001",
                  end_date = '20081201',
                  fields = 'org_facet', facets = "geo_facet")
} else
  cat("You need to specify the API key for the NY Times API, specifically for Article Search.\n",
      "Set this in the options() as options(NYTimesAPI = c('Article Search' = key)\n")

omegahat/RNYTimes documentation built on Nov. 29, 2023, 12:39 a.m.