I have a dataframe which has three columns:Machine Name,Usage Hours and Region.The first two are of character type and last is of factor type.I want to sum up usage hours per machine name so that i get total usage hours per machine and after that i want to find out the top 10 machines based on usage hours both increasing and decreasing.When i am summing up usage hours using aggregate function,its summing up to a whole number instead of displaying in hours:minutes:seconds the way the usage hours data is in the df.
Please find below a snapshot of data.
Machine Name Usage hours Region
ABC 41:43:00 APAC
DEF 0:00:00 APAC
EFH 133:20:00 APAC
So it will return the sum for each machine in hours:minutes: seconds right.Also how and which function to use for top n since I used dplyr and base r for the same,it didn't give the desired result.
Thats one possibility , but wouldnt it be better to put minutes over 60 as some number in the hours field ?
ditto for having seconds over 60 as some number of additional minutes ?
Thanks for all the inputs.Really appreciate.One more thing i wanted to ask you is after doing this and then trying to find out top 10 records,it doesn't give the top 10 records actually.It somehow gives records which have hours in two digits like below:
whereas there are records with hours in 3 digits.i have tried to do some debugging but its still not producing the desired result.I am relatively new to R.so trying to figure out things.
its simply not going to work to arrange by a character string with representations where its possible to have 0 hours and 10000minutes as one entry..
If you want to make principled comparisons of relative elapsed durations, I think you'll agree that some standardisation is necessary, like total seconds, and arrange on that.
just make a new variable, sum_seconds, with 60^2 hours + 60* minutes + seconds as its equation and use that one to arrange. use the pasted together character representation for display purposes only, not to compute on.