How to fast convert different time formats in large data frames?

前端 未结 3 895
借酒劲吻你
借酒劲吻你 2020-12-21 14:38

I want to calculate length in different time dimensions but I have problems dealing with the two slightly different time formats in my data frame column.

The origin

3条回答
  •  [愿得一人]
    2020-12-21 14:43

    or you can also use:

    time<- c("2018-07-29T15:02:05Z",
             "2018-07-29T14:46:57Z",
             "2018-10-04T12:13:41.333Z",
             "2018-10-04T12:13:45.479Z")
    
    length<-c(15.8,132.1,12.5,33.2)
    
    df<-data.frame(time,length)
    library(lubridate)
    
    # df$time2<-as_datetime(df$time)
    df$time2 <-parse_date_time(df$time, "ymd_HMS") 
    df
    

提交回复
热议问题