This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(lissyrtools) | |
library(magrittr) | |
files_h <- read_lissy_files(c("ca14h", "ca15h", "ca16h", "ca17h", "ca18h", "ca19h"), | |
col_select = "dhi") | |
files_p <- read_lissy_files(c("ca14p", "ca15p", "ca16p", "ca17p", "ca18p", "ca19p"), | |
col_select = c("pi11", "age")) | |
lissy_datasets <- merge_dataset_levels(files_h, files_p) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is an example of how to read multiple files at once in LISSY | |
# To read multiple years of one country: | |
library(tidyverse) | |
years <- c("08", "10", "14", "16") | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
# Exercise 1 | |
years <- c("08", "10", "14", "16") | |
# append all IT datasets from 2008 to 2016 | |
it_df <- purrr::map_dfr(.x = years, | |
.f = ~read.LIS(glue::glue("it{.x}p"), vars = c("year", "educlev", "educ_c", "enroll", "sex", "age" ))) | |
table(it_df$educlev, it_df$educ_c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Summer workshop - Data preparation in R -------- | |
# COPY TO LISSY: ---------------------------------------------------------- | |
library(tidyverse) | |
library(magrittr) | |
# install.packages("Hmisc") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(haven) | |
#' Download the OECD detailed National Accounts | |
#' | |
#' @description | |
#' Uses the API to the OECD tables to download the National Accounts. | |
#' | |
#' Downloads all variables for all years for the selected countries. | |
#' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
national_accounts_df <- tibble::tibble(country = c("ITA", "ITA", "ITA", "ITA", "ITA"), | |
variable = c("NFD41R", "NFD11P", "NFB3GR", "NFD42R", "NFD45R"), | |
sector = c("S14", "S14", "S14", "S14", "S14"), | |
year = c("2016", "2016", "2016", "2016", "2016"), | |
value = c(27593.2, 84325810, 227852.9, 119509.5, 1034.7)) | |
estimates_from_microdata_df <- tibble::tibble(indicator = c("D11P", "B3GR+D41R+D42R+D45R"), | |
value = c(84328052, 894699.3)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rlang) | |
library(dplyr) | |
it14ih <- data.frame(hid = 1:6, | |
hi11 = c(3601, 13190, 0, 11479, 0, 4713), | |
hi13 = c(973, 0, 0, 478, 815, 399), | |
hi12 = c(0, 0, 0, 0, 0, 842), | |
hicapital = c(40, 41, 0, 100, 0, 83), | |
hpopwgt = c(567.1, 5308.3, 666.7, | |
692.2, 254.2, 632.6) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Download the OECD detailed National Accounts | |
#' | |
#' @description | |
#' Uses the API to the OECD tables to download the National Accounts. | |
#' | |
#' Downloads all variables for all years for the selected countries. | |
#' | |
#' @details | |
#' The OECD API takes countries with ISO3. The function uses the METIS 'country' | |
#' table to convert ISO2 to ISO3. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cppyy | |
import numpy as np | |
# 'translation' of the Python function below done by ChatGPT | |
cppyy.cppdef(""" | |
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
#include <numeric> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
v <- c(8,5,1,3,5,6,7,6,3) # income | |
w <- seq(0.1, 0.9, 0.1) # weights | |
w <- w[order(v)] | |
v <- sort(v) | |
# compute πₖ |
NewerOlder