我是R的新手,尝试使用动物园合并4个数据集,2个数据集合并得很好。
但是其他2个数据集给我o / p如下:
2016-08-09 23:59:55 21.703
2016-08-09 23:59:56 21.703
2016-08-09 23:59:57 21.703
2016-08-09 23:59:58 21.703
2016-08-09 23:59:59 21.703
2016-08-10 00:00:00 21.703
2016-08-09 23:59:52 24.600
2016-08-09 23:59:53 24.600
2016-08-09 23:59:54 24.600
2016-08-09 23:59:55 24.600
2016-08-09 23:59:56 24.600
2016-08-09 23:59:57 24.599
infoA.zoo <- read.zoo(infoA.dfH, header = TRUE, tz = "")
infoB.zoo <- read.zoo(infoB.dfH, header = TRUE, tz = "")
#dfH is data.frame
#I am discretizing it over 1 sec.
merged = merge( tmpA, tmpB)
Date A B
2016-08-09 23:59:56 NA 24.600
2016-08-09 23:59:57 21.703 NA
2016-08-09 23:59:57 NA 24.599
2016-08-09 23:59:58 21.703 NA
2016-08-09 23:59:59 21.703 NA
2016-08-10 00:00:00 21.703 NA
答案 0 :(得分:0)
我尝试重现你的问题,但一切正常。我唯一改变的是,我将tmpA
和tmpB
分隔符从空格更改为';'并引用日期字符串。此外,我将参数sep=';'
添加到read.zoo
函数。
<强> TMPA 强>
"2016-08-09 23:59:55";21.703
"2016-08-09 23:59:56";21.703
"2016-08-09 23:59:57";21.703
"2016-08-09 23:59:58";21.703
"2016-08-09 23:59:59";21.703
"2016-08-10 00:00:00";21.703
<强> tmpB 强>
"2016-08-09 23:59:52";24.600
"2016-08-09 23:59:53";24.600
"2016-08-09 23:59:54";24.600
"2016-08-09 23:59:55";24.600
"2016-08-09 23:59:56";24.600
"2016-08-09 23:59:57";24.599
<强> - [R 强>
# Copy tmpA string to clipboard
X <- read.zoo('clipboard', tz="", sep=';')
# Copy tmpY string to clipboard
Y <- read.zoo('clipboard', tz="", sep=';')
merge(X,Y)
X Y
2016-08-09 23:59:52 24.600 NA
2016-08-09 23:59:53 24.600 NA
2016-08-09 23:59:54 24.600 NA
2016-08-09 23:59:55 24.600 21.703
2016-08-09 23:59:56 24.600 21.703
2016-08-09 23:59:57 24.599 21.703
2016-08-09 23:59:58 NA 21.703
2016-08-09 23:59:59 NA 21.703
2016-08-10 00:00:00 NA 21.703