How to transform a number into a date

Hello Guys,

The R language reads my database in the format: 01/12/2010 08:26:00 as number. Could you guys help me with how to transform this into two different columns: one for date and another for time ?

Thanks : )

Hello,

It is pretty hard to help you without a proper reprex. See below a dummy example of doing what you need.

library(tidyr)
library(magrittr)
#> 
#> Attaching package: 'magrittr'
#> The following object is masked from 'package:tidyr':
#> 
#>     extract

df <- data.frame(x = c("01/12/2010 08:26:00", "01/13/2010 08:26:00", "01/14/2010 08:26:00"))
df %>% tidyr::separate(x, sep = " ", c("A", "B"))
#>            A        B
#> 1 01/12/2010 08:26:00
#> 2 01/13/2010 08:26:00
#> 3 01/14/2010 08:26:00

Created on 2021-09-22 by the reprex package (v2.0.0)

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.