简体   繁体   中英

Character to Date

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!

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 "-"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM