I am new to R and Rstudio. I am currently trying to convert a column of dates that appear as mm/dd/yyyy hh:mm:ss but are classed as character. I want to turn them into date format, so that the hh:mm:ss is dropped off in a new column.
I have tried finding a solution online in guides but all the guides I have found already have the date as mm/dd/yyyy, which is not my starting point.
Here is an example of the data frame I am working with:
df <- data.frame(date=c('12/31/2016 23:57:52', '2022-02-18 22:55:45'),
sales=c(14, 29))
I have tried using separate() to make 2 columns, one for date and the other for time, but it brings back an error for an 'unexpected symbol'. here is the line of code that brings back that error:
separate(df, date, into=c('date_1', 'time') sep=' ')
Please help me out if you have the time, I feel like the solution is something simple I just can't figure out what.