Skip to content

Instantly share code, notes, and snippets.

@tengpeng
Created October 29, 2016 00:45
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 tengpeng/63b222be183b64ffff5ed7fc1d05c5ab to your computer and use it in GitHub Desktop.
Save tengpeng/63b222be183b64ffff5ed7fc1d05c5ab to your computer and use it in GitHub Desktop.
Access date and time components in R
as.POSIXlt(as.Date(i))
orders$day <- orders$dd_mmm_yy$mday # day of month
orders$month <- orders$dd_mmm_yy$mon+1 # month of year (zero-indexed)
orders$year <- orders$dd_mmm_yy$year+1900 # years since 1900
# http://stackoverflow.com/questions/8126537/extract-date-elements-from-posixlt-and-put-into-data-frame-in-r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment