Learn R Programming

rdatamarket (version 0.6.5)

rdatamarket-package: Data access API for DataMarket.com

Description

Interacts with DataMarket.com, fetching data in timeseries (zoo) and long form (suitable for reshape), and metadata on datasets.

Arguments

Quick start

Just find the data you want on http://datamarket.com/ and then paste the URL from your browser into dmlist or dmseries: plot(dmseries("http://datamarket.com/data/set/zy0/#ds=zy0!8o7=2")) plot(dmseries("http://data.is/nyFeP9")) l <- dmlist("http://data.is/nyFeP9") or into dminfo to get the dataset metadata: ds <- dminfo("http://data.is/nyFeP9")

DS parameters

In functions that take a parameter named ds, that parameter can be:
  • a dataset ID ("17tm")
  • a DS string ("17tm!kqc=a") consisting of a dataset ID along with some dimension filtering specifications; for more about DS strings, see Datamarket API documentation at http://datamarket.com/api/v1/#about-ds
  • a query string ("foo=bar&ds=17tm!kqc=a&baz=xyzzy") containing such a string in a ds parameter
  • a URL ("http://datamarket.com/data/set/17tm/#ds=17tm!kqc=a") containing such a query string after ? or #
  • such a URL represented by a redirect ("http://data.is/r6JEsC") in a short-URL service (data.is, bit.ly, is.gd, t.co, url.is)
  • a dataset object, obtained by calling dminfo.
Thus when viewing any dataset on datamarket.com, you can copy the URL from your browser bar and paste into a call to dmseries or dmlist to load the same data into R, or a call to dminfo to get a dataset object with which to make data queries.

Dimension filtering

The functions dmseries and dmlist can accept parameters named for the dimensions of the dataset, in order to filter the data: dmlist("17tm", Country="Algeria")

Examples

Run this code
oil <- dminfo("17tm")
print(oil)
series <- dmseries(oil, Country="Yemen")
lis <- dmlist(oil, Country=c("Algeria", "Angola"))

Run the code above in your browser using DataLab