将列从军事时间转换为标准时间 [英] Converting column from military time to standard time
本文介绍了将列从军事时间转换为标准时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将显示道路交通事故时间的列从军事时间转换为标准时间。数据如下所示:
I'm trying to convert a column showing the time of road traffic accidents from military time to standard time. The data looks like this:
Col1 Time..24hr.
1 1404
2 322
3 1945
4 1005
5 945
然后,我想转换为12小时,因此'322'我想以'3'为例。感谢很多
I'd then like to convert to 12hr so for '322' I'd like to make '3', for instance. Thanks a lot
推荐答案
根据您的标准 - 322表示为3,2045为20 - 如何除以100然后用 trunc()
向0舍入。
Given your criteria -- that 322 is represented as 3 and 2045 is 20 -- how about dividing by 100 and then rounding towards 0 with trunc()
.
time_24hr <- c(1404, 322, 1945, 1005, 945)
trunc(time_24hr / 100)
这篇关于将列从军事时间转换为标准时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文