Krishna Kalyan
Krishna Kalyan

Reputation: 1702

Converting minutes in numeric to Date time object in R

I have a dataframe with values in minutes

0 , 30 , 60 ... 1410

I need to cast them as

00:00:00, 00:30:00, 01:00:00 ... 23:30:00

How can I achieve this using R.

Thanks

Upvotes: 0

Views: 45

Answers (1)

akrun
akrun

Reputation: 887851

We could try

sprintf("%d:%02d:00", v1%/%60, v1%%60)
#[1] "0:00:00"  "0:30:00"  "1:00:00"  "23:30:00"

data

v1 <- c(0, 30, 60, 1410)

Upvotes: 3

Related Questions