Home > front end >  Convert time format from chr to hours/minutes/seconds in R
Convert time format from chr to hours/minutes/seconds in R

Time:05-21

I want to change a format from chr to hours/minutes/seconds. Can someone help me?

Values are in this format: 00:30:00

CodePudding user response:

Not really sure what you're going for here, but...

The as.ITime(...) function in the data.table package does this:

as.ITime('00:30:00')
## [1] "00:30:00"

The result is stored internally as seconds:

as.integer(as.ITime('00:30:00'))
## [1] 1800

CodePudding user response:

Try this:

  as.Date(variable, format = '%H:%M:%S')
  •  Tags:  
  • r
  • Related