knitr::opts_chunk$set( collapse = TRUE, comment = "#>", echo = TRUE )
Within the kolada database there are two different types of data.
The municipal data contains KPIs for the Swedish kommuner and landsting, there are about 4500 KPIs within the database. On organizational unit level the data is less comprehensive, but there are still quite a few KPIs on this level. Each KPI is currently measured once a year, and the data may be divided by gender. I.e. for each KPI there may be at most three values, based on gender being female, male and a total.
source: https://github.com/Hypergene/kolada#kolada-api
devtools::install_github("shwva184/lab5") runApp("inst", display.mode = "showcase")
library(Lab5Assign) library(dplyr) require(shiny) require(shinythemes)
to run the API interface :
{r } runGitHub(repo = 'shwva184/lab5',username ='shwva184',subdir = 'inst', display.mode = "showcase")
The Kolada API client provides access to standardized key performance indicators (KPI) concerning Swedish municipalities and organizational units.The following function is modified to give out KPI_Id,Title and description. For a proper query URL, you need metadata such as id of a KPI(KPI Id) to retrieve the associated data.Title displays the name of the KPI. Description gives information needed to understand KPI.
Note: We need KPI_Id to retrieve data from Tab3.
This functions fetches the above mention fields from URL : http://api.kolada.se/v2/kpi
head(data.frame(Lab5Assign::getMetadata(entity ='kpi')),5) #Displaying only top 5 here.
Here we are retrieving information on ID associated with a particular municipality , names of all available municipalities and municipality type is either L (for County Council (swedish: Landsting)) or K for municipality (swedish: Kommun).
Note: We need Municipality_Id to retrieve data from Tab3
This functions fetches the above mention fields from URL : http://api.kolada.se/v2/municipality
head(data.frame(Lab5Assign::getMetadata(entity ='municipality')),5)#Displaying only top 5 here.
The municipal data contains KPIs for the Swedish kommuner and landsting, there are about 4500 KPIs within the database. Each KPI is currently measured once a year, and the data may be divided by gender i.e. for each KPI there may be at most three values, based on gender being Female, Male and a Total.
The structure of the data is::
"KPI ID","Municipality ID","Year","Count(No. of members)","Gender", "Status","Value"
KPI_ID : ID associated with KPI Municipality_ID: ID associated with Municipality Year: the year KPI has been measured. Count: number of members associated with the selected Municipality and KPI Gender: Man(M), Kvinna(K) and Total(T) Status column: shows if the average is available. Value column : contains the unweighted average.(An unweighted average describes the average for Sweden's municipalities / regions - what it looks like in an average municipality / region. It is calculated by summing the value of all municipalities or regions and dividing by 290 and 21, respectively. If one or more municipalities / regions do not have data for the current key figure, the value is divided by the number that has values. Example: An unweighted average value for all municipalities regarding Merit value in year 9 will describe the value for an average municipality.)
To retrieve data for a specific kpi(ie. N02924) in a municipality(ie. 1440) URL : http://api.kolada.se/v2/data/kpi/N02924/municipality/1440
head(fetch_given_kpiandmuncipality_id("N02924",1440),10)#Displaying only top 10 here.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.