'Convert characters that correspond to time difference to numeric values in minutes
Let's say I have a vector of characters that correspond calculated time like:
calc<-c("1:17","0:46","11:25") and I want to convert it to numeric values of minutes like calc<-c(77,46,685) . Is there a way to do it?
Solution 1:[1]
Try the following base R option using str2lang + gsub
> eval(str2lang(sprintf("c(%s)", toString(gsub(":", "*60+", calc)))))
[1] 77 46 685
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
