Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. if(!require("pacman")) { install.packages("pacman") }
  2.  
  3. devtools::install_github("pachamaltese/datos")
  4. pacman::p_load(purrr, dplyr, tidyr, datos)
  5.  
  6. # I need to know what's going on with this "selective" error
  7. sessionInfo()
  8.  
  9. # inspect datos::paises (countries)
  10. paises
  11.  
  12. # group paises (countries) by pais (country)
  13. por_pais <- paises %>%
  14. group_by(pais, continente) %>%
  15. nest()
  16.  
  17. por_pais
  18.  
  19. por_pais$data[[1]]
  20.  
  21. # function to obtain one regression per country
  22. modelo_pais <- function(df) {
  23. lm(esperanza_de_vida ~ anio, data = df)
  24. }
  25.  
  26. # apply regression function to each country
  27. modelos <- map(por_pais$data, modelo_pais)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement