Giter VIP home page Giter VIP logo

gemrtables's Introduction

gemrtables

The goal of gemrtables is to generate the Global Education Monitoring (GEM) Report statistical tables.

The Global Education Monitoring Report (GEM Report), is an editorially independent, authoritative, and evidence-based annual report that monitors progress towards the global education goal and targets adopted at the UN General Assembly in September 2015. The gemrtables package provides an easy way to obtain data from the UNESCO Institute for Statistics (UIS) by accessing its API and several others sources.

Installation

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("northeastloon/gemrtables")

Usage

gemrtables() is the primary function for this package, generating the statistical tables in a ‘wide’ data format in excel, or a ‘long’ format.

In addition, the gemrtables package provides three categories of functions: import, clean, and summarise. The import functions read data from SDMX url queries, the GEM cedar SQL database, and other sources.

Some indices are calculated at the country level and then are aggregated at the regional level or the income level. Also, it is possible to calculate those indices directly at the regional or the income level.

Example

This is a basic example which shows you how to solve a common problem:

library(gemrtables)
df <- gemrtables(region = "UIS.region", ref_year = 2016, export = FALSE, key = y)

You should substitute ‘key’ for the UIS api subscription.

Drake plan

In a complex analysis pipeline, like gemrtables, it is useful a workflow manager for the R code. With the ‘drake’ package changing the code is easier and more efficient. Downloading and caching data requires time, it is not efficient re-runs all the code every time a piece of code change a little. When something changes, drake rebuilds only things that need to be rebuilt. This saves time and reduces errors.

This is an example which shows you how to use drake in the gemrtables code:

# source("pkgs.R")
source("R/aggregates_function.R")
source("R/clean_functions.R")
source("R/import_functions.R")
source("R/merge_files.R")
source("R/other_import.R")
source("R/uis_alternative_access.R")
source("R/uis_import.R")
source("R/gemrtables_function.R")

# drake_plan() stores the plan as targets and commands in a dataframe.
param_plan <-
  drake::drake_plan(
    gem_params = gemrtables(ref_year = 2016, drake = TRUE)
  )

# import/clean functions
import_clean_plan <-
  drake::drake_plan(
    uis_data = uis(),
    other_data = other()
  )

# Summarize
summary_plan <-
  drake::drake_plan(
    # other_data = dplyr::bind_rows(wb_data, eurostat_data, oecd_data, un_aids_data, gcpea_data, unicef_wash_data,
    #                               unicef_ecce_learn_data, unicef_ecce_books_data, bullying_data, ict_skills_data, chores_data),
    all_data = dplyr::bind_rows(uis_data, other_data),
    long_data = long_format(),
    wide_format = format_wide(long_data)
  )

# Create a workflow plan data frame for the whole plan
gemrtables_plan <- dplyr::bind_rows(param_plan, 
                                    import_clean_plan, 
                                    summary_plan)

# Run the plan
drake::make(gemrtables_plan) #prework = "devtools::load_all()", lock_envir = FALSE

# Configuration list object
config <- drake::drake_config(gemrtables_plan)

# Interactive dependency graph of all inputs and outputs
drake::vis_drake_graph(config)

# Clean: drake::which_clean(), clean(), file_out()
# Explore chache: drake::cached()

gemrtables's People

Contributors

calcita avatar gmathieux avatar northeastloon avatar

Watchers

 avatar

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.