Skip to content

Requesting indicator data for multiple countries with get_indicator() function #8

Description

@gdickens

Hey,

Thanks for your work putting this together.

I'm trying to download all available data for the same four countries. Unfortunately, there doesn't appear to be a simple way to do this on V1 of their API. But, it does appear to be possible to download data for more than one country at once with a relatively minor tweak of the get_indicator() function code.

In case it's helpful for your next update or others using the package:

fnc_get_indicator_n_geos<-function (Country, indicator) 
{
  country_string<-paste(Country,collapse = "&areaCode=")
   url <- paste0("https://unstats.un.org/sdgs/UNSDGAPIV5/v1/sdg/Indicator/Data?indicator=", 
                 indicator, "&areaCode=",country_string)
  datcall <- jsonlite::fromJSON(url)
  page <- as.data.frame(datcall$data)
  return(page)

}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions