Skip to content

Instantly share code, notes, and snippets.

@rcquan
Created November 22, 2014 06:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rcquan/7122c5ad7bcb1440e6ff to your computer and use it in GitHub Desktop.
Save rcquan/7122c5ad7bcb1440e6ff to your computer and use it in GitHub Desktop.
# Convert variable from factor into "Date" class
medMis$Effective.Date <- as.character(medMis$Effective.Date)
medMis$Effective.Date <- as.POSIXct(medMis$Effective.Date, format = "%m/%d/%Y")
# Order dataset by Effective.Date from 1990-2014
medMis <- (medMis[order(medMis$Effective.Date),])
# Create time-series data
medMis_month <- as.data.frame(table(format(medMis$Effective.Date, "%Y-%m-01")), stringsAsFactors = FALSE)
medMis_plot <- as.data.frame(table(format(medMis$Effective.Date, "%Y-%m")), stringsAsFactors = FALSE)
# Change column name to "Time" and convert to date-time class
colnames(medMis_month)[1] <-"Time"
medMis_month$Time <- as.POSIXct(medMis_month$Time)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment