0
mutate(Time = as.POSIXct(Time, format = "%H:%M:%S"))

I'm currently trying to mutate my time variable to that instead of being a character variable, it is in the as.POSIXct format. But, everytime I apply this format, I always get this output: 2020-02-29 07:25:00. The time normally looks like this in just the normal character form: 07:25:00 .

How do I get rid of the date??

Cassidy
  • 395
  • 1
  • 11

1 Answers1

0

Try using the hms package ("hours minutes seconds").

library(hms)

Time <- "2020-02-29 07:25:00"

as_hms(as.POSIXct(Time))
# 07:25:00
  • That did help change the column back to be time, but how can I make it an object of class `POSIXct`? I need it to be this class so I can use `scale_x_datetime` later on. – Cassidy Feb 29 '20 at 15:17
  • Do you need datetime? Or `scale_x_time()` for just the time? –  Feb 29 '20 at 15:24
  • Actually, yes, I only need time on the x-axis to be scaled. I'm just not sure how to use that function. `scale_x_time` sounds like what I would need to use though. I want the times to be 30 minutes apart from one another – Cassidy Feb 29 '20 at 15:27