Skip to content

Instantly share code, notes, and snippets.

@thanhyds1998
Created September 26, 2025 08:41
Show Gist options
  • Save thanhyds1998/9a1beb70b5892f2e4257e28b445081c1 to your computer and use it in GitHub Desktop.
Save thanhyds1998/9a1beb70b5892f2e4257e28b445081c1 to your computer and use it in GitHub Desktop.
Date_time
# Load the package
library(lubridate)
# Choose the right parser
ymd("2025-09-25") # works for "YYYY-MM-DD"
dmy("25/09/2025") # works for "DD/MM/YYYY"
mdy("09-25-2025") # works for "MM-DD-YYYY"
# Apply to the dataset
M2SGS$Date <- dmy(M2SGS$Date)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment