A column with olympic results in different formats

23 Views Asked by At

I have a dataset having results of different swimmers in the olympics. The challenge is that I want to format the Column having the results but here is an example of what it containsResults for Olympic swimmers

I have excluded swimmers who were unable to finish, were disqualified and those who didn't start

mutate(Results=na_if(Results,"Disqualified")) %>%
mutate(Results=na_if(Results,"Did not finish")) %>%
mutate(Results=na_if(Results,"Did not start")) %>%
drop_na(Results)

The remaining rows have values in with various kind of formats for example

'00:01:03.800000'
'00:22:23.200000'
'22:36.4est'
'23:04.0est'
'51.98'
'52'
'52.19'
'52.3'
'52.51'
'52.78'
'52.7'

Is there a way to have all these rows in the same format

I have tried to use this code

Swimming$Results <-as.POSIXct(strptime(Swimming$Results,format="%H:%M:%S"))
Swimming$Results

The results exclude the numeric values and instead returns NA for numerics

0

There are 0 best solutions below