-3

I have tried my best using the split function and others, but to no avail.

lmo
  • 37,904
  • 9
  • 56
  • 69

1 Answers1

0

We can use read.table/read.csv with the sep option.

read.table(text=as.character(df1$datetime), sep=' ', 
         col.names=c('date', 'time'),
            header=FALSE, stringsAsFactors=FALSE)
#        date time
#1 01/01/2011 0:00
#2 01/01/2011 1:00
#3 01/01/2011 2:00
#4 01/01/2011 3:00
#5 01/01/2011 4:00

Or with tidyr

library(tidyr)
separate(df1, datetime, into= c('date', 'time'), sep=' ')
akrun
  • 874,273
  • 37
  • 540
  • 662