Reputation: 1829
I have a Dataframe with two columns, ID
and BillableDuration
(in seconds)
ID BillableDuration
1 140
2 35
3 543
4 200
I wanted to convert this convert the values in BillableDuration
in minutes, I used the following:
library(lubridate)
BillableDuration_seconds<- period_to_seconds(hms(df$BillableDuration))
BillableDuration_mins <- BillableDuration_seconds/60;
new_df <- cbind(df, BillableDuration_mins)
Expected Output:
ID BillableDuration BillableDuration_mins
1 140 2.33
2 35 0.58
3 543 9.05
4 200 3.33
But i got the following error:
Warning message:In .parse_hms(..., order = "HMS", quiet = quiet) : Some strings failed to parse
What I am doing wrong here, is there a better method to do this.
Thanks in advance
Upvotes: 1
Views: 3334
Reputation: 887541
We can divide the second column by 60
df1$BillableDuration_mins <- df1$BillableDuration/60
Upvotes: 1