GithubHelp home page GithubHelp logo

fredr's Introduction

#FredR: R Interface to the Federal Reserve Economic Data API Travis-CI Build Status Coverage Status

This package provides an interface to the Federal Reserve Economic Data (FRED) API. FRED covers 240,000 US and international macroeconomic time series from 77 sources (including the World Bank, OECD, and BIS).

FredR has been designed in a way that gives a user a complete interface to all available functionalities of the API. Currently, the package is still poorly documented (improving on this will be the next step). However, the naming conventions used in the package map one-to-one to the official API calls, so one can for now use the official API documentation (available here) to see the meaning of particular functions and parameters.

##Installation FredR is currently only available on Github, so you will need Hadley's devtools in order to install it:

devtools::install_github("jcizel/FredR")

Quick Demonstration

In order to use the API, you first need to create an account here: http://api.stlouisfed.org/api_key.html. Once you have the account, copy-paste your API key and supply it is a string argument to FredR function, like so:

api.key = '...'  # substitute ... with your API key

Next, you need to initialize FredR:

fred <- FredR(api.key)

Call to FredR generates a list of functions each of which performs a specific type of query to the API. Each functions returns a data.table object containing the result of the query.

Let's view all the available functions in FredR:

str(fred,1)

Ok, let's get to work. Say, that we want to find all series, whose name contains a string 'GDP':

gdp.series <- fred$series.search("GDP")

gdp is now a data.table containing all available GDP series and their properties.

To see which one to use for further analysis, one can dig deeper:

library(pipeR)
library(dplyr)

gdp.series %>>%
select(
    id,
    title,
    observation_start,
    observation_end,
    popularity
) %>>%
arrange(
    desc(as.numeric(popularity))
)

Let's say that we decide to download the time series data for the series with id = 'GDPC1' (Real Gross Domestic Product in the U.S.):

gdp <- fred$series.observations(series_id = 'GDPC1')

Plot the result:

gdp %>>%
select(
    date,
    value
) %>>%
mutate(
    date = as.Date(date),
    value = as.numeric(value)
) ->
    dt

require(ggplot2)
qplot(data = dt, x = date, y = value, geom = 'line')

fredr's People

Contributors

jcizel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fredr's Issues

FRED API to require HTTPS August 18.

Hello,

I work on FRED at the St. Louis Fed. Beginning on August 18, 2015, the FRED API will require HTTPS requests. This change will help provide secure communication with the FRED API. An automatic redirect will forward HTTP requests to HTTPS. We recommend that you update the URLs in your code. The API currently supports HTTPS to allow you to test your applications with this secure protocol.

Please contact us at [email protected] or 314-444-FRED (3733) if you have questions or concerns. Thanks for using FRED and the FRED API.

Sincerely,
Keith Taylor
[email protected]

Installation command

missing quotes; does not work in Ubuntu 14.04
devtools::install_github(jcizel/FredR) >> devtools::install_github("jcizel/FredR")

Unable to load series - issue in "xml2dt" ?

Hi there,

Many thanks for the development effort, this tool's going to be great. I am trying to run search queries using RStudio, I have an api.key but any call to functions such as "series.search" will bring the following error:

Error in rbindlist(., fill = TRUE) : unused argument (fill = TRUE)

I think this might be related to the function xml2dt but I don't have any notion in XML...

Do you have any clue how I can fix that ?

Many thanks, Nic

Issues with FredR

Hi:

I am fairly new to R but have followed your instructions on devtool installation and I believe successfully installed FredR and have an api key. However when I follow your instructions on fred <- FredR(api.key) I get an error message that FredR function cant be found. Specifically here is what I get:

Installing FredR
"C:/PROGRA1/R/R-311.3/bin/x64/R" --vanilla CMD INSTALL "C:/Users/Ardavan/AppData/Local/Temp/Rtmp2BKcCm/devtools1a00c13091/jcizel-FredR-cef0c9c"
--library="C:/Users/Ardavan/Documents/R/win-library/3.1" --install-tests

  • installing source package 'FredR' ...
    ** R
    ** inst
    ** tests
    ** preparing package for lazy loading
    Warning: replacing previous import by 'dplyr::between' when loading 'FredR'
    Warning: replacing previous import by 'dplyr::last' when loading 'FredR'
    ** help
    *** installing help indices
    ** building package indices
    ** testing if installed package can be loaded
    *** arch - i386
    Warning: replacing previous import by 'dplyr::between' when loading 'FredR'
    Warning: replacing previous import by 'dplyr::last' when loading 'FredR'
    *** arch - x64
    Warning: replacing previous import by 'dplyr::between' when loading 'FredR'
    Warning: replacing previous import by 'dplyr::last' when loading 'FredR'
  • DONE (FredR)

    fred <- FredR(api.key)
    Error: could not find function "FredR"

Can you assist?

Error when running minimal example

Hi,
I am trying to search for the GDP series as in your most basic example. When running:

gdp.series <- fred$series.search("GDP")

I get the error message:

Space required after the Public Identifier
SystemLiteral " or ' expected
SYSTEM or PUBLIC, the URI is missing

I must be making some very silly mistake but don't know what.

Thanks!

Problem Querying Data: Error setting the option for # 3

When trying to pull certain data, such as the Treasury Maturity Rates from the FRED API, I receive the following error:

as.data.frame(fred$series.observations(series_id = 'GS10'))

Error setting the option for # 3 (status = 43) (enum = 81) (value = 0x7f85745483f0): 
A libcurl function was given a bad argument CURLOPT_SSL_VERIFYHOST no longer
 supports 1 as value!

Revisited this useful tool and find it's not functioning

fred$series.search("Population")
Unescaped '<' not allowed in attributes values
attributes construct error
Couldn't find end of Start Tag series line 38
Unescaped '<' not allowed in attributes values
attributes construct error
Couldn't find end of Start Tag series line 136
Unescaped '<' not allowed in attributes values
attributes construct error
Couldn't find end of Start Tag series line 139
Unescaped '<' not allowed in attributes values
attributes construct error
Couldn't find end of Start Tag series line 151
Unescaped '<' not allowed in attributes values
attributes construct error
Couldn't find end of Start Tag series line 189
Unescaped '<' not allowed in attributes values
attributes construct error
Couldn't find end of Start Tag series line 192
Unescaped '<' not allowed in attributes values
attributes construct error
Couldn't find end of Start Tag series line 227
Unescaped '<' not allowed in attributes values
attributes construct error
Couldn't find end of Start Tag series line 237
Unescaped '<' not allowed in attributes values
attributes construct error
Couldn't find end of Start Tag series line 348
Unescaped '<' not allowed in attributes values
attributes construct error
Couldn't find end of Start Tag series line 384
Unescaped '<' not allowed in attributes values
attributes construct error
Couldn't find end of Start Tag series line 391
Unescaped '<' not allowed in attributes values
attributes construct error
Couldn't find end of Start Tag series line 394
Unescaped '<' not allowed in attributes values
attributes construct error
Couldn't find end of Start Tag series line 402
Unescaped '<' not allowed in attributes values
attributes construct error
Couldn't find end of Start Tag series line 425
Opening and ending tag mismatch: a9 line 427 and seriess
Premature end of data in tag c2 line 427
Premature end of data in tag a9 line 404
Premature end of data in tag c2 line 404
Premature end of data in tag a9 line 396
Premature end of data in tag c2 line 396
Premature end of data in tag a9 line 393
Premature end of data in tag c2 line 393
Premature end of data in tag a9 line 386
Premature end of data in tag c2 line 386
Premature end of data in tag a9 line 350
Premature end of data in tag c2 line 350
Premature end of data in tag a9 line 239
Premature end of data in tag c2 line 239
Premature end of data in tag a9 line 229
Premature end of data in tag c2 line 229
Premature end of data in tag a9 line 194
Premature end of data in tag c2 line 194
Premature end of data in tag a9 line 191
Premature end of data in tag c2 line 191
Premature end of data in tag a9 line 153
Premature end of data in tag c2 line 153
Premature end of data in tag a9 line 141
Premature end of data in tag c2 line 141
Premature end of data in tag a9 line 138
Premature end of data in tag c2 line 138
Premature end of data in tag a9 line 40
Premature end of data in tag c2 line 40
Premature end of data in tag seriess line 2
Error: 1: Unescaped '<' not allowed in attributes values
2: attributes construct error
3: Couldn't find end of Start Tag series line 38
4: Unescaped '<' not allowed in attributes values
5: attributes construct error
6: Couldn't find end of Start Tag series line 136
7: Unescaped '<' not allowed in attributes values
8: attributes construct error
9: Couldn't find end of Start Tag series line 139
10: Unescaped '<' not allowed in attributes values
11: attributes construct error
12: Couldn't find end of Start Tag series line 151
13: Unescaped '<' not allowed in attributes values
14: attributes construct error
15: Couldn't find end of Start Tag series line 189
16: Unescaped '<' not allowed in attributes values
17: attributes construct error
18: Couldn't find end of Start Tag series line 192
19: Unescaped '<' not allowed in attributes values
20: attributes construct error
21: Couldn't find end of Start Tag series line 227
22: Unescaped '<' not allowed in attributes values
23: attributes const

Unable to install API key

I am working in RStudio on Windows. I have a St. Louis Fed API key and stored it in a variable called api.key. However, when I try to run fred <- FredR(api.key) I receive this error message:

Error in readChar(con, 5L, useBytes = TRUE) : cannot open the connection
In addition: Warning message:
In readChar(con, 5L, useBytes = TRUE) :
cannot open compressed file './inst/data/categories.RData', probable reason 'No such file or directory'

Any ideas? I have been able to install an API key with the acs package api.key.install function.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.