How to convert dd/mm/yy to yyyy-mm-dd in R

后端 未结 6 2187
日久生厌
日久生厌 2020-12-20 06:16

I have a vector with dates values in this format dd/mm/yy e.g.(27/06/16). I want to convert this in this format yyyy-mm-dd e.g.(2016-06-27) for logical comparison. I am usin

6条回答
  •  渐次进展
    2020-12-20 07:03

    Using dplyr

    df.with.converted.date <- df.with.original.date %>%
      mutate(new.date.var = as.character(as.Date(old.date.var, "%m/%d/%Y"),"%Y%m%d"))
    

    For example this will convert "5/3/2019" to 20190503

提交回复
热议问题