r - 使用 cbind 合并 xts 对象时 colnames 的行为
问题描述
如果我使用cbind
合并两个matrices
ordata.frames
具有相同colnames
的那些colnames
在新的matrix
or中保持不变data.frame
:
df <- data.frame(test = c(1,2))
df.merge <- cbind(df,df)
df.merge
test test
1 1 1
2 2 2
但是,如果我对xts
对象执行相同操作,则会将数值添加到colnames
:
df.xts <- xts(df, order.by = as.POSIXct(c("2019-02-18 13:00","2019-02-18 14:00"), tz = "UTC"))
df.xts.merge <- cbind(df.xts, df.xts)
df.xts.merge
test test.1
2019-02-18 13:00:00 1 1
2019-02-18 14:00:00 2 2
xts
有没有办法通过合并对象来防止重命名列?
解决方案
推荐阅读
- android - Android ROOM:如何返回未持久化的别名列
- json - BigQuery 以不同方式处理(假定)相同格式的 JSON - 一个接受,一个拒绝
- charts - Qlik Sense 图表中的虚线?
- c# - 如何在 WPF C# 中使用后台工作人员运行 while 循环而不冻结 UI 屏幕?
- c# - 如果前一列不为空,则添加新列
- sql - INFORMATION_SCHEMA:这可用于在同一数据库中的所有表中查找所有相同命名的列
- python - 使用 Pandas.read_hdf 函数在 Python 3.7 中读取 HDF 文件时出错
- excel - 在形状中使用 OnAction 得到错误 1004
- c++ - 陷入输入 C++ 的无限循环
- javascript - 如何使用新的输入数据更新“sortNotes”功能?