I have a field in a R dataframe, say called OriginTime. The field has basically two types of values, read in from several excel files and rbinded together. Example df follows:
OriginTime <- c(0.777888, 0.999888, 0.25, 0.3755, "12:24", "05:59")
The entire column is character values. I want to convert the entire column to time field in the format hh:mm. But whenever I attempt to convert the column values, say using chron::times, the rows with an already hh:mm format get turned into NA values, and the decimal values are correctly reformated. I have attempted various methods to resolve but to no avail. One example
ifelse(substr(OriginTime,3,3)!=":",chron::times(as.numeric(as.character(OriginTime))),OriginTime)