Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. library(gapminder)
  2. head(gapminder)
  3.  
  4. # A tibble: 6 x 6
  5. country continent year lifeExp pop gdpPercap
  6. <fct> <fct> <int> <dbl> <int> <dbl>
  7. 1 Afghanistan Asia 1952 28.8 8425333 779.
  8. 2 Afghanistan Asia 1957 30.3 9240934 821.
  9. 3 Afghanistan Asia 1962 32.0 10267083 853.
  10. 4 Afghanistan Asia 1967 34.0 11537966 836.
  11. 5 Afghanistan Asia 1972 36.1 13079460 740.
  12. 6 Afghanistan Asia 1977 38.4 14880372 786.
  13.  
  14. y <- unique(gapminder$country, incomparables = FALSE)
  15. length(y)
  16. [1] 142
  17. df.names <- paste(y, sep = "")
  18.  
  19. for(i in 1:length(y)){
  20. d.frame[,i] <- gapminder$pop %>% filter(gapminder$country==y[i])
  21. assign(df.names[i], d.frame)
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement