Last active
April 12, 2021 22:49
-
-
Save juanchiem/5b81bb5e083e26cb7e285e13cb059ed4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
pacman::p_load(tidyverse, googlesheets4) | |
# Planilla que tiene 2 filas de encabezados (fila 2 y 3), y debemos fusionar. | |
# La primer fila es una inclusión extra para faciltar el proceso. | |
u <- "https://docs.google.com/spreadsheets/d/1zf0UqTNiYl7z241Fkr1LtP52D3G9nIzzjyl3zbM8eaU/edit?usp=sharing" | |
planilla <- gs4_get(u) | |
# leemos las filas con info para los nombres de las columnas | |
data_head <- planilla %>% read_sheet(n_max = 2) | |
# fusionamos los contenidos de las celdas para generar los nombres compuestos de cada variable | |
new_names <- data_head %>% | |
t() %>% | |
as_tibble() %>% | |
unite(., col = "name", V1, V2, na.rm=TRUE, sep = "_") %>% | |
pull(name) | |
# leemos el cuerpo del dataset, pero indicamos los nuevos nombres | |
dat_full <- planilla %>% read_sheet(skip = 3, col_names = new_names) | |
dat_full |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment