如何分隔日期和时间示例:R 中的 12/25/17 0:00?

How to separate date and time example: 12/25/17 0:00 in R?

如果 the_date 列如下所示,我如何将日期和时间分成 2 个不同的变量:

the_date
12/25/17 0:00

如何单独检索

转换为 DateTime 后,我们提取每个组件

library(lubridate)
library(dplyr)
df1 %>%
    mutate(v1 = mdy_hm(v1), 
           Year = year(v1),
           Month = month(v1), 
           Date = day(v1), 
           time = format(v1, "%H:%M:%S"))
# A tibble: 1 x 5
#   v1                   Year Month  Date time    
#   <dttm>              <dbl> <dbl> <int> <chr>   
#1 2017-12-25 00:00:00  2017    12    25 00:00:00

数据

df1 <- tibble(v1 = "12/25/17 0:00")