This package provides access to the API for the United States Federal Register. The API provides access to all Federal Register contents since 1994, including Executive Orders by Presidents Clinton, Bush, and Obama and all “Public Inspection” Documents made available prior to publication in the Register. The API returns basic details about each entry in the Register and provides URLs for HTML, PDF, and plain text versions of the contents thereof, and the data are fully searchable. The federalregister package provides access to all version 1 API endpoints.
Installing the package
The package can be installed from GitHub:
if (!library('devtools')) {
install.packages('devtools')
library('devtools')
}
install_github('rOpenGov/federalregister')
library('federalregister')Executive Orders, by President
One cool feature of the Federal Register API is the ability to retrieve Executive Orders. Constructing the necessary API request, for example, to retrieve all Executive Orders for 2013 from President Obama is a bit complicated:
Doing it using federalregister is quite a bit easier:
library('federalregister')
clinton <- fr_search(presidential_document_type='executive_order',
president='william-j-clinton', per_page=1000)
bush <- fr_search(presidential_document_type='executive_order',
president='george-w-bush', per_page=1000)
obama <- fr_search(presidential_document_type='executive_order',
president='barack-obama', per_page=1000)
# number of Executive Orders
c(clint=clinton$count, bush=bush$count, obama=obama$count)Prevalence of Agency Mentions
Each Federal Registry entry includes data on agency mentions (i.e., what agencies the entry applies to). We can use this information to analyze which agencies are getting attention, even over time.
Text-mining the Federal Register
The API returns metadata about entries in the Federal Register, including links to HTML, PDF, and plain text versions of entries in the Federal Register. Using federalregister to retrieve the plain text URLs, it is then possible to reconstruct the contents of the Register for use in, e.g., some kind of text mining analysis.
arecord <- fr_get('E9-1719')
full <- httr::content(httr::GET(arecord[[1]]$raw_text_url), "text", encoding = "UTF-8")
cat(substring(full, 1, 1000))<html>
<head>
<title>Federal Register, Volume 74 Issue 15 (Monday, January 26, 2009)</title>
</head>
<body><pre>
[Federal Register Volume 74, Number 15 (Monday, January 26, 2009)]
[Presidential Documents]
[Pages 4673-4678]
From the Federal Register Online via the Government Publishing Office [<a href="http://www.gpo.gov">www.gpo.gov</a>]
[FR Doc No: E9-1719]


