[R] cbind giving NA's?

Dennis Murphy djmuser at gmail.com
Fri Aug 26 14:03:02 CEST 2011


Hi:

Try this:

require('xts')
 merge.zoo(zoo(a), zoo(b), all = c(TRUE, TRUE))
           ZWD.UGX SCHB.Close
2010-03-31      NA      28.02
2010-04-01  7.6343         NA
2010-04-02  7.6343         NA
2010-04-03  7.5458         NA
2010-04-04  7.4532      28.30
2010-04-05  7.4040      28.38
2010-04-06  7.3317      28.21
2010-04-07      NA      28.31
2010-04-08      NA      28.47

HTH,
Dennis

On Fri, Aug 26, 2011 at 3:58 AM, Hasan Diwan <hasan.diwan at gmail.com> wrote:
> On 26 August 2011 03:37, R. Michael Weylandt <michael.weylandt at gmail.com> wrote:
>> If you could, dput() them so we can see everything about them. You also
>> might see if merge() gives you more expected behavior....
>
> Ok...
>> dput(a)
> structure(c(7.6343, 7.6343, 7.5458, 7.4532, 7.404, 7.3317), class = c("xts",
> "zoo"), .indexCLASS = "Date", .indexTZ = "", index = structure(c(1270105200,
> 1270191600, 1270278000, 1270364400, 1270450800, 1270537200), tzone =
> "", tclass = "Date"), .Dim = c(6L,
> 1L), .Dimnames = list(NULL, "ZWD.UGX"))
>> dput(b)
> structure(c(28.02, 28.3, 28.38, 28.21, 28.31, 28.47), .indexCLASS =
> "Date", .indexTZ = "", src = "yahoo", updated =
> structure(1314356091.21457, class = c("POSIXct",
> "POSIXt")), class = c("xts", "zoo"), index = structure(c(1270072800,
> 1270418400, 1270504800, 1270591200, 1270677600, 1270764000), tzone =
> "", tclass = "Date"), .Dim = c(6L,
> 1L), .Dimnames = list(NULL, "SCHB.Close"))
>> merge(a,b)
>> merge(a,b)
>           ZWD.UGX SCHB.Close
> 2010-04-01      NA      28.02
> 2010-04-01  7.6343         NA
> 2010-04-02  7.6343         NA
> 2010-04-03  7.5458         NA
> 2010-04-04  7.4532         NA
> 2010-04-05      NA      28.30
> 2010-04-05  7.4040         NA
> 2010-04-06      NA      28.38
> 2010-04-06  7.3317         NA
> 2010-04-07      NA      28.21
> 2010-04-08      NA      28.31
> 2010-04-09      NA      28.47
>> q()
>
> So, no, merge doesn't work...
> --
> Sent from my mobile device
> Envoyait de mon telephone mobil
>
> ______________________________________________
> R-help at r-project.org 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.
>



More information about the R-help mailing list