Created
April 24, 2019 14:02
-
-
Save gonzalezgouveia/7867ad3a0623ef04b7ac77062cadff6a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# crear datos tidy u ordenados | |
population_tidy <- population_data%>% | |
# filtrar para algunos paises de HispanoAmérica | |
filter(country %in% c('Argentina', | |
'Chile', | |
'Colombia', | |
'Ecuador', | |
'Mexico', | |
'Panama', | |
'Peru', | |
'Spain', | |
'Uruguay', | |
'Venezuela')) %>% | |
# juntar años el filas o renglones | |
gather(key = year, value = population, -1) %>% | |
# mutar años como entero y población en millones | |
mutate(year = as.integer(year), | |
population10 = population/1000000) %>% | |
# filtrar por años | |
filter(year > 1940, | |
year < 2020) %>% | |
# agrupar y crear ranking para ordenar | |
group_by(year) %>% | |
mutate(ordering = min_rank(population10) * 1.0) %>% | |
ungroup() %>% | |
# filtrar primeros 5 paises por año | |
filter(ordering >= 6) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment