Home > Back-end >  Character to Date
Character to Date

Time:08-09

I am having some problems with changing dates from Excel (characters in R) into date in R.

Knowing that I am using : as.Date(Data$Datum, "d%/m%/y%") But it returns NA NA NA..

And the date starts in Excel on : 1-1-2019 , but in R it shows : "43466"

I have tried also lubridate : dmy(Data$Datum) , but it also returns all the values as NA.

Could you please help me with this situation!

Thanks in advance!

CodePudding user response:

Fix this part and everything will be ok,

date <- as.Date(Data$Datum, "%m-%d-%Y")

Place the % sign in front and use Y not y because it is 2019 and not 19.

Finally, separate mdY with "-"

  • Related