Last active
February 20, 2019 12:55
-
-
Save pachadotdev/5b68d80f1454589eb0d89f7079b36867 to your computer and use it in GitHub Desktop.
trying to reproduce esperanza_de_vida error in R4DS es
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
if(!require("pacman")) { install.packages("pacman") } | |
devtools::install_github("pachamaltese/datos") | |
pacman::p_load(purrr, dplyr, tidyr, datos) | |
# I need to know what's going on with this "selective" error | |
sessionInfo() | |
# inspect datos::paises (countries) | |
paises | |
# group paises (countries) by pais (country) | |
por_pais <- paises %>% | |
group_by(pais, continente) %>% | |
nest() | |
por_pais | |
por_pais$data[[1]] | |
# function to obtain one regression per country | |
modelo_pais <- function(df) { | |
lm(esperanza_de_vida ~ anio, data = df) | |
} | |
# apply regression function to each country | |
modelos <- map(por_pais$data, modelo_pais) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment