Search code examples
rurl

extracting a time series from a url where by hoovering over the series you can see the values of that series


I want to extract the time series from this time series plot

Inflation, consumer prices (annual %)

As you can see by hoovering over the plot you can see the data values.

I tried something like

 library(rvest)
html_url<-read_html("https://data.worldbank.org/indicator/FP.CPI.TOTL.ZG")

But I am not sure how to move one


Solution

  • The wbstats, WDI and worldbank packages are specifically for downloading World Bank data. (The rworldmap package may also be of interest.) For the first two packages just listed try the code shown below. Use ? to review additional arguments supported by these functions. Also see the wbstats package vignette. Also the World Bank API page may be of interest.

    library(wbstats)
    dat <- wb_data("FP.CPI.TOTL.ZG")
    
    library(WDI)
    dat2 <- WDI(indicator = "FP.CPI.TOTL.ZG")