Skip to content

Commit

Permalink
Generar variable de tiempo y reordenar columnas
Browse files Browse the repository at this point in the history
  • Loading branch information
segasi committed Oct 24, 2019
1 parent 6ab68f8 commit 84ae08c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions 02_codigo/analisis_victimas_homicidio_2015_2019.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,21 @@ victimas <-
gather(enero:diciembre,
key = "mes",
value = "num_victimas")

### Generar diversas variable relacionadas con el tiempo y reordenar columnas ----

victimas %>%
mutate(mes_num = case_when(mes == "enero" ~ 1,
mes == "febrero" ~ 2,
mes == "marzo" ~ 3,
mes == "abril" ~ 4,
mes == "mayo" ~ 5,
mes == "junio" ~ 6,
mes == "julio" ~ 7,
mes == "agosto" ~ 8,
mes == "septiembre" ~ 9,
mes == "octubre" ~ 10,
mes == "noviembre" ~ 11,
mes == "diciembre" ~ 12),
fecha = make_date(ano, mes_num)) %>%
select(fecha, año = ano, mes, everything())

0 comments on commit 84ae08c

Please sign in to comment.