Date format check & cleaning

Viewed 31

I have an issue with investigating and cleaning date values for a specific column in a database with more than 700,000 observations.

The first issue is that the missing values you see below don't show up when I run the following lines of codes:

colSums(test == "")
colSUms(test == " ")

Actually, one of the first things I did is recoding any empty cells or white space into NAs, but these empty cells don't turn up as NAs either.

see missing values in top row

Also, I am quite sure that not all dates are of the format dd/mm/yyyy timestamp AM/PM. I need to run some kind of wildcard (?) to see which ones rows have an incorrect format, and either change or remove them.

I don't need the timestamp, so I already tried splitting the columns. THat worked, but I don't know if some rows get committed in this way due to the incorrect date formats. I used the code:

test[c("date", "time")] <- str_split_fixed(test$date, ' ', 2)

Finally, maybe it's good to know that I only need the month and year in separate columns.

Hope you can help!

0 Answers
Related