Loading FRED data with quantmod: can I specify dates?

I am loading data from FRED using the quantmod library (by Jeffrey A. Ryan). With YAHOO and GOOGLE data, I can set start and end dates. Can this also be done for FRED data?

The help page does not display "from" and "to" as parameters of the quandmod getSymbols function, from which I deduced that this is currently not possible.

Is there a way to set the range for the data that I need to load, or do I need to download the entire data set and discard the data that I do not need?

Thank you for your help. Below is the code that illustrates the context:

Dates are ignored when loading from FRED:

# environment in which to store data data <- new.env() # set dates date.start <- "2000-01-01" date.end <- "2012-12-31" # set tickers tickers <- c("FEDFUNDS", "GDPPOT", "DGS10") # import data from FRED database library("quantmod") getSymbols( tickers , src = "FRED" # needed! , from = date.start # ignored , to = date.end # ignored , env = data , adjust = TRUE ) head(data$FEDFUNDS) head(data$FEDFUNDS) FEDFUNDS 1954-07-01 0.80 1954-08-01 1.22 1954-09-01 1.06 1954-10-01 0.85 1954-11-01 0.83 1954-12-01 1.28 

EDIT: solution

Thanks to GSee's suggestion below, I use the following code to subset data in the date range above:

 # subset data to within time range dtx <- data$FEDFUNDS dtx[paste(date.start,date.end,sep="/")] 

Here I extracted the xts data from the environment before acting on it. My subsequent question addresses alternatives.

Follow up question

I asked a few subsequent questions: get xts objects from the environment

+6
source share
3 answers

You need to download all the data and a subset later. getSymbols.FRED does not support the from argument, for example getSymbols.yahoo .

+5
source

Alternatively, you can download FRED data from Quandl ( http://www.quandl.com/help/r ), which offers over 4 million data sets, including all FRED data. API and R. ("Quandl") are available. Data can be returned in several formats, for example. data frame ("raw"), ts ("ts"), zoo ("zoo") and xts ("xts"). For example, to load GDPPOT10 and specify dates and return it as an xts object, you just need to:

 require(Quandl) mydata = Quandl("FRED/GDPPOT", start_date="2005-01-03",end_date="2013-04-10",type="xts") 
+5
source

Quandl does not seem to offer all of the FRED data, at least in terms of data frequency. Quandl most likely offers only annual data that is not useful in many circumstances.

+1
source

All Articles