简体   繁体   中英

Make date readable by R

I have a column in a dataset right now formatted for example as "Aug-19" which represents 08/01/2019 in mm/dd/yyyy format. How do I convert this into a format that can be read by R?

You can use lubridate package.

dates <- c("Aug-19", "Sep-19")

dates_myd <- paste0(dates, "-01")

lubridate::myd(dates_myd)

With lubridate we can also do

myd(dates, truncated = 1)
#[1] "2019-08-01" "2019-09-01"

data

dates <- c("Aug-19", "Sep-19")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM