课程: R for Data Science: Lunch Break Lessons

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

as.Date()

as.Date()

- [Instructor] Dates and times in R can be confusing. And once you understand the date structures, all of it starts to make sense, so let's spend some time looking at date, POSIXlt and POSIXct. In this session, I'm going to focus on the date object. And that's only date. Dates and times will come later. So let's take a quick look at this. First of all, we start with as.Date. as.Date and the capital is important. I can give this a string format, quote 2022-03- oh, let's call it 23. So this would be March 23rd, 2022. And if I run that, you'll see that I return 2022-03-23. as.Data is actually telling me that it has converted this to a date object. We can take a look at what as.Date actually returns by typing in str and a parentheses around as.Date and we'll see what kind of structure as.Date returns. Well, structure tells us that the as.Date command returns a date object in the format of 2022-03-22. Perfect. Now…

内容