knitr::opts_chunk$set( comment = "#>", collapse = TRUE, warning = FALSE, message = FALSE )
enigma
is an R package to search and retrieve data from Enigma.io
Enigma holds government data and provides a really nice set of APIs for data, metadata, and stats on each of the datasets. That is, you can request a dataset itself, metadata on the dataset, and summary statistics on the columns of each dataset.
Stable version from CRAN
install.packages("enigma")
Or, install development version from GitHub
install.packages("devtools") devtools::install_github("ropengov/enigma")
library('enigma')
Enigma API calls require an API key. Go to your account at https://app.enigma.io/settings/account and your key should be on the left hand side near the bottom. You can either pass in your API key each function call with the key
parameter, or save your key as either an R environment variable (use the name ENIGMA_KEY
), or an R option (use the name enigmaKey
).
out <- enigma_data(dataset='us.gov.whitehouse.visitor-list', select=c('namelast','visitee_namelast','last_updatedby'))
Some metadata on the results
out$info
Look at the data, first 6 rows for readme brevity
head(out$result)
out <- enigma_stats(dataset='us.gov.whitehouse.visitor-list', select='total_people')
Some summary stats
out$result[c('sum','avg','stddev','variance','min','max')]
Frequency details
head(out$result$frequency)
out <- enigma_metadata(dataset='us.gov.whitehouse')
Paths
out$info$paths
Immediate nodes
out$info$immediate_nodes
Children tables
out$info$children_tables[[1]]
First, get columns for the air carrier dataset
dset <- 'us.gov.dot.rita.trans-stats.air-carrier-statistics.t100d-market-all-carrier' head(enigma_metadata(dset)$columns$table[,c(1:4)])
Looks like there's a column called distance that we can search on. We by default for varchar
type columns only frequency
bake for the column.
out <- enigma_stats(dset, select='distance') head(out$result$frequency)
Enigma provides an endpoint .../export/<datasetid>
to download a zipped csv file of the entire dataset.
enigma_fetch()
gives you an easy way to download these to a specific place on your machine. And a message tells you that a file has been written to disk.
enigma_fetch(dataset='com.crunchbase.info.companies.acquisition')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.