-3

I'm new to R, and I'm having a dataset which has a column which has both date and time together, and the date and time data are not in the correct format I have two queries 1) few dates are separated by "/" and few by "-" how to replace "-" with "/" for all values 2)Few date formats are in dd/mm/yyyy format whereas few are in dd/m/yy format, how to have an alignment through this

assuming the column name is "Date Stamp" and the dataset name being "data.frame" Please suggest me for the above two cases. Thanks alot in advance!

Regards. Manoj Chandra

1 Answers1

1

We can use separate

library(tidyr)
Data.Frame %>%
           separate(`Date&Timestamp`, into = c('Date', 'timestamp'))

Note: separate will automatically detect the delimiter. It is not clear from the OP's post,whether there is a delimiter. The sep argument is there in separate if it needs to be used

akrun
  • 874,273
  • 37
  • 540
  • 662
  • I'm having a dataset which has a column which has both date and time together, and the date and time data are not in the correct format I have two queries 1) few dates are separated by "/" and few by "-" how to replace "-" with "/" for all values 2)Few date formats are in dd/mm/yyyy format whereas few are in dd/m/yy format, how to have an alignment through this assuming the column name is "Date Stamp" and the dataset name being "data.frame" Please suggest me for the above two cases. Thanks alot in advance! – Manoj Chandra May 27 '17 at 13:25
  • @ManojChandra Why don't you provide a small reproducible example by updating your post – akrun May 27 '17 at 14:34