Description Usage Arguments Details Value References Examples
Download a gzipped csv file of a dataset.
1 2 3 4 5 |
dataset |
Dataset name. Required. |
select |
(character) Vector of columns to be returned with each row. Default is to return all columns. |
search |
(character) Filter results by only returning rows that match a search query. By default this searches the entire table for matching text. To search particular fields only, use the query format "@fieldname query". To match multiple queries, the | (or) operator can be used eg. "query1|query2". |
where |
(character) Filter results with a SQL-style "where" clause.
Only applies to numerical columns - use the |
conjunction |
one of "and" or "or". Only applicable when more than one
|
sort |
(character) Sort rows by a particular column in a given direction. + denotes ascending order, - denotes descending. See examples. |
path |
File name and path of output zip file. Defaults to write a zip
file to your home directory with name of the dataset, and file extension
|
key |
(character) Required. An Enigma API key. Supply in the function
call, or store in your |
poll_sleep |
(integer) Time to sleep between polling events to fetch
data. For very large datasets, it could take a while to be ready. By
default, we poll continuously. If you are requesting a large dataset and/or
have not much left on your allowed requests with Enigam (see
|
... |
Named curl options passed on to |
input |
The output from |
Note that enigma_fetch
downloads the file,
and gives back a path to the file. In a separte function,
enigma_read
, you can read in the data.
enigma_fetch
doesn't read in data in case the file
is very large which may make your R session crash or slow down
significantly.
This function makes a request to ask Enigma to get a download ready. We then poll the provided URL from Enigma until it is ready. Once ready we fetch it and write it to disk.
If file exists already, we overwrite it.
A (character) path to the file on your machine
https://app.enigma.io/api#exporting
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ## Not run:
## After obtaining an API key from Enigma's website, pass in your key to
## the function call or set in your options (see above instructions for the
## key parameter) If you pass in your key to the function call use the
## key parameter
# Fetch a dataset
res <- enigma_fetch('org.un.comtrade.1')
enigma_read(res)
# Use the select parameter to limit fields returned
res <- enigma_fetch('org.un.comtrade.1',
select = c("country_area", "year", "flow", "trade_usd"))
enigma_read(res)
# Use the search parameter to query entire table or particular fields
res <- enigma_fetch('org.un.comtrade.1', search = "export")
enigma_read(res)
# Use the search parameter to query entire table or particular fields
res <- enigma_fetch(dataset = 'org.un.comtrade.1',
where = "trade_usd > 90000000",
select = c("country_area", "year", "trade_usd"))
enigma_read(res)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.