I want to split a 'timestamp' column in my dataset into two separate one, the dataset is very lengthy
I expect two different columns, one for date '2014-09-22'and other for time '07:47:00'
I want to split a 'timestamp' column in my dataset into two separate one, the dataset is very lengthy
I expect two different columns, one for date '2014-09-22'and other for time '07:47:00'
You can use the strsplit function and split on a space. That's implying your data has no spaces after which it doesn't seem so.
df$nwcolumn <- strsplit(df$timestamp, " ")
Try this:
library(tidyr)
df <- data.frame(x = c("2014-09-32 07:47:00", "2016-09-13 14:32:00", "2017-09-18 12:42:00"))
df %>% separate(x, c("A", "B"), sep = " ")
Output is:
A B
<chr> <chr>
2014-09-32 07:47:00
2016-09-13 14:32:00
2017-09-18 12:42:00