Skip to content

Instantly share code, notes, and snippets.

@joffilyfe
Last active September 14, 2017 19:14
Show Gist options
  • Save joffilyfe/3b44330e366404eabc526141f484b32c to your computer and use it in GitHub Desktop.
Save joffilyfe/3b44330e366404eabc526141f484b32c to your computer and use it in GitHub Desktop.
# É preciso instalar o pacote lubridate
library(lubridate)
parse_dates <- function(dt, column, formats) {
dt[, column] <- parse_date_time(x = dt[, column], orders=formats)
return(dt)
}
dataset <- read.csv("secretaria/data/dengue-2015.csv")
for (coluna in c("DT_NOTIFIC", "DT_NASC", "DT_ALRM", "DT_INVEST", "DT_OBITO")) {
dataset <- parse_dates(dataset, coluna, c("%Y%m%d", "%d/%m/%Y"))
}
write.csv(dataset, file="secretaria/data/dengue-2015-data.csv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment