Hi there,
I need to merge/bind two time series objects (from RPackage: timeSeries) by
column. The theory is laid out nicely, even for overlapping indices.
In my example, I have overlapping indices ("01.01.2001"), where in one time
series I have one data point and in the other redundant data. Default usage of
merge and cbind would lead to the result that the one data point would be
replicated (see example below). However, I do not like the replicating feature
and would like to have the NA's filled instead.
Desired output, would be:
TS.1 SS.2
2001-01-01 23.1 23.1
2001-01-01 NA 23.4
Is there a slick way to produce above result? Thank you for your answer - help
is really appreciated.
Kind regards,
Bernhard.
<--------------------------------------------------------------------------------------------------->
# R Console example:
require(timeSeries)
date <-timeDate("01.01.2001", format = "%d.%m.%Y")
test1 <- timeSeries(c(23.1), charvec = date)
test2 <- timeSeries(c(23.1, 23.4), charvec = c(date, date))
colnames(test2) <- "SS.2"
merge(test1, test2)
GMT
TS.1 SS.2
2001-01-01 23.1 23.1
2001-01-01 23.1 23.4
cbind(test1, test2)
Fehler in cbind(deparse.level, ...) : number of rows must match
cbind(test2, test1)
GMT
SS.2 TS.1
2001-01-01 23.1 23.1
2001-01-01 23.4 23.1
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.