Convert yyyymmdd string to Date class in R

后端 未结 4 2119
时光取名叫无心
时光取名叫无心 2020-11-29 07:03

I would like to convert these dates with format YYYYMMDD to a Date class.

dates <- data.frame(Date = c(\"20130707\", \"20130706\", \"20130705\", \"2013070         


        
4条回答
  •  北海茫月
    2020-11-29 07:50

    Classic R:

    > start_numeric <- as.Date('20170215', format = '%Y%m%d');
    > start_numeric
    [1] "2017-02-15"
    > format(start_numeric, "%Y%m%d")
    [1] "20170215"
    

提交回复
热议问题