Home > Enterprise >  integer to date format in R
integer to date format in R

Time:08-02

I want to change the column of "dob" to date format. I used the below code but did not see changes in my data.

Date = as.Date(ped$dob)

Can you guide me through this?

        ID   sex  dob     yob 
1:  126000   M    20220523 2022    
2: 375000    M    20220523 2022  

CodePudding user response:

Try this: note the big Y in the format

as.Date(as.character(ped$dob), '%Y%m%d')
  • Related