Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save olafghanizadeh/96e52537e09b85ea5550ca8c6bf2658e to your computer and use it in GitHub Desktop.
Save olafghanizadeh/96e52537e09b85ea5550ca8c6bf2658e to your computer and use it in GitHub Desktop.
library(tidyquant)
library(dplyr)
library(dygraphs)
jpDebt <- tq_get(x = c("DEBTTLJPA188A"), get = "economic.data", from = "1994-01-01")
jpDebtSelect <- select(jpDebt, 3)
jpDebtTs <- ts(jpDebtSelect, start=c(1994, 1), end=c(2015, 4), frequency=4)
jpDebtSmooth <- predict(td(jpDebtTs ~ 1, method = "denton-cholette", conversion = "average"))
jpDebtSmooth
jpGdp <- tq_get(x = c("JPNRGDPEXP"), get = "economic.data", from = "1994-01-01")
jpGdpSelect <- select(jpGdp, 3)
jpGdpTs <- ts(jpGdpSelect, start=c(1994, 1), end=c(2015, 4), frequency=4)
jpGdpTs
data <- cbind(jpDebtTs, jpGdpTs)
dygraph(data, main = "Japanese public debt and GDP") %>%
dySeries("jpDebtTs", label = "Debt as a share of GDP", axis="y2") %>%
dySeries("jpGdpTs", label = "GDP")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment