Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
311 views
in Technique[技术] by (71.8m points)

r - Convert numeric to date

I'd like to convert this type of numeric values to a date but it doesn't work.

20100727 for instance

I tried to convert the numeric to character and applied this :

as.Date("20100727", "Y%d%m")

but it doesn't work.

How can I do ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You were setting wrong order of month and date values (in your code was Year, Date, Month, should be Year, Month, Date).

as.Date("20100727", "%Y%m%d")
[1] "2010-07-27"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...