【发布时间】:2017-10-30 09:14:31
【问题描述】:
我有一个包含 24 小时制时间列的数据框:
canopy_understory trap_no file_name date time temp light_intensity
<chr> <int> <chr> <dttm> <time> <dbl> <dbl>
1 c 11 trap11c_160314.txt1 16-01-09 14:00:00 35.542 41
2 c 11 trap11c_160314.txt2 16-01-09 15:00:00 28.953 4
3 c 11 trap11c_160314.txt3 16-01-09 16:00:00 27.468 1
为了删除秒列,我在 R 中运行此代码:
all_files_hobo$time <- strftime(all_files_hobo$time, format = "%H:%M")
运行此代码后,我有以下数据框
canopy_understory trap_no file_name date time temp light_intensity
<chr> <int> <chr> <dttm> <chr> <dbl> <dbl>
1 c 11 trap11c_160314.txt1 16-01-09 06:00 35.542 41
2 c 11 trap11c_160314.txt2 16-01-09 07:00 28.953 4
3 c 11 trap11c_160314.txt3 16-01-09 08:00 27.468 1
如您所见,秒数已过,列已从 变为 ,但时间也不同。这是有问题的。我可以每次都加 8,但我担心这里会发生更阴险的事情,并且在不久的将来事情会变得一团糟。为什么 strftime 改变了我的时代?
【问题讨论】:
-
阅读这个人我认为这是一个时区问题,但我仍然不知道如何解决这个问题。
-
使用
tz参数strftime设置时区 -
如何设置时区以使其不发生任何变化?
-
很可能是您所在的当前时区或 UTC。见
OlsonNames()