How to transform a dataframe of characters to the respective dates?

后端 未结 2 2155
無奈伤痛
無奈伤痛 2020-12-21 14:03

I noticed already a couple of times that working with dates doesn\'t allow for using the usual tricks in R. Say I have a dataframe Data with Dates (see below), and I want to

2条回答
  •  甜味超标
    2020-12-21 14:47

    How about

    str(as.data.frame(lapply(Data,as.Date,format="%d %B %Y")))
    # 'data.frame':   6 obs. of  4 variables:
    #  $ Rep1:Class 'Date'  num [1:6] 12898 12898 13907 13907 13907 ...
    #  $ Rep2:Class 'Date'  num [1:6] 13278 13278 14217 14217 14217 ...
    #  $ Rep3:Class 'Date'  num [1:6] 13600 13600 14340 14340 14340 ...
    #  $ Rep4:Class 'Date'  num [1:6] 13831 13831 14669 14669 14669 ...
    

提交回复
热议问题