Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement