Skip to content

Instantly share code, notes, and snippets.

@JosepER
Last active May 24, 2023 07:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JosepER/a99f5f7a208e53b1bfecfa50a439d6bf to your computer and use it in GitHub Desktop.
Save JosepER/a99f5f7a208e53b1bfecfa50a439d6bf to your computer and use it in GitHub Desktop.
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)
# Exercise 2
years <- c(1991:2019)
years <-str_sub(years, 3, 4)
de_df <- purrr::map_dfr(.x = years,
.f = function(x) {
left_join(read.LIS(glue::glue("de{x}p"),
vars = c("hid", "year", "pi11", "educlev", "educ_c", "enroll", "sex", "age" )),
read.LIS(glue::glue("de{x}h"),
vars = c("hid", "year" )),
by = c("year", "hid"))
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment