英文:
I need to split date time into two columns
问题
I tried a couple of codes but failed. 我尝试了几段代码但失败了。
I checked the youtube to understand it but did not succeed. 我查看了YouTube以了解,但没有成功。
The youtube link https://www.youtube.com/watch?v=Phib0IUNdg8 YouTube链接 https://www.youtube.com/watch?v=Phib0IUNdg8
I looked into R for the data science book under the Dates and Time page. 我查阅了数据科学书中关于日期和时间的部分。
I have used as. date() function it didn't work. 我使用了 as.date() 函数,但它没有起作用。
I tried to separate () too but no result. 我也尝试了分开 (),但没有结果。
I am missing a concept please let me know. 我缺少一个概念,请告诉我。
Please help me. 请帮助我。
英文:
I tried a couple of codes but failed. I checked the youtube to understand it but did not succeed. The youtube link https://www.youtube.com/watch?v=Phib0IUNdg8
I looked into R for the data science book under the Dates and Time page. I have used as. date() function it didn't work. I tried to separate () too but no result. I am missing a concept please let me know.
Please help me.enter image description here
答案1
得分: 1
"lubridate" 和 "hms" 包允许提取日期和时间。
一个示例:
date_time_text <- c("2023-04-28 18:04:02")
date_time <- lubridate::ymd_hms(date_time_text)
date <- as.Date(date_time)
time <- hms::as_hms(date_time)
英文:
The lubridate
and hms
packages allow extraction of dates and times.
An example:
date_time_text <- c("2023-04-28 18:04:02")
date_time <- lubridate::ymd_hms(date_time_text)
date <- as.Date(date_time)
time <- hms::as_hms(date_time)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论