Functions for interacting directly with the Quandl API to offer data in a number of formats usable in R, downloading a zip with all data from a Quandl database, and the ability to search. This R package uses the Quandl API. For more information go to < https://docs.quandl.com>. For more help on the package itself go to < https://www.quandl.com/tools/r>.
License provided by MIT.
For more information please contact [email protected]
To install the devtools package:
install.packages("devtools") library(devtools) install_github("quandl/quandl-r")
To install the most recent package from CRAN type:
Note that the version on CRAN might not reflect the most recent changes made to this package.
The Quandl package functions use the Quandl API. Optional Quandl API query parameters can be passed into each function. For more information on supported query parameters, please see the Quandl API documentation page. Once you find the data you would like to load into R on Quandl, copy the Quandl code from the description box and paste it into the function.
data <- Quandl("NSE/OIL")
To create a graph of Google's performance month-over-month:
collapse is a Quandl API query parameter. Click here for a full list of query parameter options.
The supported return types for the
Quandl(code) function are:
To request a specific type, assign the
type argument the return type:
data <- Quandl('NSE/OIL', type = "xts")
zoo, xts, and ts have their own time series date formats. For example:
data <- Quandl('NSE/OIL', collapse = "quarterly", type = "zoo", limit = 3)
data will have indexes
2015 Q2, and
Open High Low Last Close Total Trade Quantity Turnover (Lacs)2015 Q1 459.8 462.8 452.45 454.45 454.95 277225 1265.842015 Q2 448.0 451.7 445.10 447.80 446.80 352514 1576.932015 Q3 456.0 465.0 454.15 456.80 456.75 174154 797.79
If you want the time series index to be displayed as dates, you will need to set
force_irregular = TRUE:
data <- Quandl('NSE/OIL', collapse = "quarterly", type = "zoo", limit = 3, force_irregular = TRUE)
data will now have indexes
Open High Low Last Close Total Trade Quantity Turnover (Lacs)2015-03-31 459.8 462.8 452.45 454.45 454.95 277225 1265.842015-06-30 448.0 451.7 445.10 447.80 446.80 352514 1576.932015-09-30 456.0 465.0 454.15 456.80 456.75 174154 797.79
If you want to get multiple codes at once, delimit the codes with ',', and put them into an array. This will return a multiset.
merged_data <- Quandl(c('GOOG/NASDAQ_AAPL', 'GOOG/NASDAQ_MSFT'))
You can also specify specific columns to retrieve. For example, if you only want column 1 from
GOOG/NASDAQ_AAPL and column 2 from
merged_data <- Quandl(c('GOOG/NASDAQ_AAPL.1', 'GOOG/NASDAQ_MSFT.2'))
An entire database's data can be downloaded. For example, to download the database
For a full list of optional query parameters for downloading an entire database, click here.
To retrieve Datatable data, provide a Datatable code to the Quandl datatables function:
data = Quandl.datatable('ZACKS/FC')
The output format is
data.frame. Given the volume of data stored in datatables, this call will retrieve the first page of the ZACKS/FC datatable. You may turn on pagination to return more data by using:
data = Quandl.datatable('ZACKS/FC', paginate=TRUE)
This will retrieve multiple pages of data and merge them together as if they were one large page. In some cases, however, you will still exceed the request limit. In this case we recommend you filter your data using the available query parameters, as in the following example:
Quandl.datatable('ZACKS/FC', ticker=c('AAPL', 'MSFT'), per_end_date.gt='2015-01-01', qopts.columns=c('ticker', 'per_end_date', 'tot_revnu'))
In this query we are asking for more pages of data, ticker values of either AAPL or MSFT and a per_end_date that is greater than or equal to 2015-01-01. We are also filtering the returned columns on ticker, per_end_date and tot_revnu rather than all available columns.
Searching Quandl from within the R console is now supported. The search function is:
Quandl.search(query = "Search Term", page = n, database_code = "Specific database to search", silent = TRUE|FALSE)
Which outputs to console a list containing the following information for every item returned by the search:
A search for Oil, searching only the National Stock Exchange of India (NSE).
Quandl.search("Oil", database_code = "NSE", per_page = 3)
Oil India LimitedCode: NSE/OILDesc: Historical prices for Oil India Limited<br><br>National Stock Exchange of India<br><br>Ticker: OIL<br><br>ISIN: INE274J01014Freq: dailyCols: Date | Open | High | Low | Last | Close | Total Trade Quantity | Turnover (Lacs)Oil Country Tubular LimitedCode: NSE/OILCOUNTUBDesc: Historical prices for Oil Country Tubular Limited<br><br>National Stock Exchange of India<br><br>Ticker: OILCOUNTUB<br><br>ISIN: INE591A01010Freq: dailyCols: Date | Open | High | Low | Last | Close | Total Trade Quantity | Turnover (Lacs)Gulf Oil Corporation LimitedCode: NSE/GULFOILCORDesc: Historical prices for Gulf Oil Corporation Limited (GULFOILCOR), (ISIN: INE077F01027), National Stock Exchange of India.Freq: dailyCols: Date | Open | High | Low | Last | Close | Total Trade Quantity | Turnover (Lacs)