r - 选择日期/时间单元格时如何强制 R 保持时间值?
问题描述
我有一列日期/时间值,我正在选择顶部单元格和底部单元格:
> time1 <- Angels.rolling$date.hour[1]
> time1
[1] "2014-02-17 UTC"
> time2 <- Angels.rolling$date.hour[(nrow(Angels.rolling))]
> time2
[1] "2018-02-14 01:00:00 UTC"
time1 应该显示为“2014-02-17 00:00:00 UTC”,因为这是顶部单元格的值,但它似乎删除了时间,因为它是午夜。该列已使用 lubridate 的 ymd_hms() 格式化。
如何在不丢失数据的情况下将整个日期和时间值拉入我的 time1 变量?
解决方案
The time is still in the object, it's just not printed by default. If you want the time to be printed you can use format
.
format(Angels.rolling$date.hour[1], '%Y-%m-%d %T %Z')
推荐阅读
- php - 如果在第二个数组上找到第一个数组的值,则替换并回显它
- vb.net - 如何生成 Im、Re 倍频程滤波器
- php - 无法请求令牌
- xgboost - xgboost模型的内部节点预测
- firebase - 在颤振应用程序中包含 firebase_storage 的最佳方法是什么?
- kubernetes - 为什么我的 kubernetes webook 只在创建时调用而不在更新时调用?
- c# - 文本框限制值和小数位的简单验证代码是什么?
- testng - 使用 TestNG SoftAssertions 测试通过时如何打印通过消息
- c++ - 在表达式 left() = right() 中,为什么 right() 先排序?
- elasticsearch - 如何在 Elasticsearch 中存储布尔数组并执行 XOR 操作?