Skip to content

Instantly share code, notes, and snippets.

@juanchiem
Last active June 25, 2020 11:16
Show Gist options
  • Save juanchiem/73c2528e3c10e4107dfb75c54a28c9af to your computer and use it in GitHub Desktop.
Save juanchiem/73c2528e3c10e4107dfb75c54a28c9af to your computer and use it in GitHub Desktop.
library(tidyverse)
library(googlesheets4)
gapminder <- gs4_get("https://docs.google.com/spreadsheets/d/1U6Cf_qEOhiR9AZqTqS3mbMF3zt2db48ZP5v3rkrAEJY/edit#gid=780868077")
# gapminder es una planilla de google sheets que tiene 5 hojas (una por continente)
# Cuando cada hoja tiene toda la información que necesitamos (como este caso)
gapminder_data <- gapminder %>% sheet_names() %>%
map_df(~ read_sheet(gapminder, sheet = .)) %>%
bind_rows()
# Cuando necesitamos el nombre de cada planilla en una nueva columna (suponiendo que no existe la columna continente)
gapminder_data <- tibble(continents = gapminder %>% sheet_names()) %>%
mutate(data = map(continents, ~read_sheet(gapminder, sheet = .x))) %>%
tidyr::unnest(cols = c(data))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment