split one column into with space in between in R

后端 未结 1 706
情深已故
情深已故 2021-01-16 18:26

I have a data frame whose first 20 obs are like this:

     userID                      appName           startTime             endTime endResult Handset Gend         


        
相关标签:
1条回答
  • 2021-01-16 18:56

    Use strftime to process the timestamps to what you desire, eg:

    strftime("2012-07-28 00:58:05","%Y-%m-%d")
    [1] "2012-07-28"
    strftime("2012-07-28 00:58:05","%H:%M:%S")
    [1] "00:58:05"
    

    It's vectorised so you can use:

    dfr$start.date <- strftime(dfr$startTime,"%Y-%m-%d")
    dfr$start.time <- strftime(dfr$startTime,"%H:%M:%S")
    
    0 讨论(0)
提交回复
热议问题