Re: [R] outer join of xts's

2020-01-04 Thread Joshua Ulrich
On Fri, Jan 3, 2020 at 8:20 AM Eric Berger wrote: > > Hi Joshua, > Thanks for the comment but I guess I prefer a different behavior. If > merge.xts() cannot handle the objects I pass in, I want it to fail. > In fact, I typically adopt a naming convention where the variable name > indicates the

Re: [R] outer join of xts's

2020-01-03 Thread Eric Berger
Hi Joshua, Thanks for the comment but I guess I prefer a different behavior. If merge.xts() cannot handle the objects I pass in, I want it to fail. In fact, I typically adopt a naming convention where the variable name indicates the type. In my normal coding style my example would look like: aXts

Re: [R] outer join of xts's

2020-01-03 Thread Joshua Ulrich
On Fri, Jan 3, 2020 at 1:14 AM Eric Berger wrote: > > Hi Gabor and Duncan, > Thanks for your comments. As Gabor points out, Duncan's suggestion > does not work. > For those interested, here is some minimal reproducible example to illustrate > > library(xts) > dtV <- as.Date("2019-01-01")+1:5 > a

Re: [R] outer join of xts's

2020-01-02 Thread Eric Berger
Hi Gabor and Duncan, Thanks for your comments. As Gabor points out, Duncan's suggestion does not work. For those interested, here is some minimal reproducible example to illustrate library(xts) dtV <- as.Date("2019-01-01")+1:5 a <- xts(x=rnorm(5),order.by=dtV) a1 <- a[1:3,] a2 <- a[2:4,] a3 <-

Re: [R] outer join of xts's

2020-01-02 Thread Gabor Grothendieck
join = "left" only applies with merge.xts if there are two objects. If there are more it acts the same as join = TRUE.. See the Details section of ?merge.xts On Thu, Jan 2, 2020 at 1:29 PM Duncan Murdoch wrote: > > On 02/01/2020 9:31 a.m., Eric Berger wrote: > > Hi Gabor, > > This is great,

Re: [R] outer join of xts's

2020-01-02 Thread Duncan Murdoch
On 02/01/2020 9:31 a.m., Eric Berger wrote: Hi Gabor, This is great, thanks. It brought the time down to about 4 seconds. The command do.call("merge.xts",L) also works in this case. Suppose that instead of the default "outer" join I wanted to use, say, a "left" join. Is that possible? I tried a

Re: [R] outer join of xts's

2020-01-02 Thread Gabor Grothendieck
> It is not clear what multiway left join means but merge.zoo (though > not merge.xts) supports a generalized all= argument which is a logical > vector having the same length as L that can be TRUE or FALSE for each > object merged. The objects corresponding to TRUE will have all their > times

Re: [R] outer join of xts's

2020-01-02 Thread Gabor Grothendieck
It is not clear what multiway left join means but merge.zoo (though not merge.xts) supports a generalized all= argument which is a logical vector having the same length as L that can be TRUE or FALSE for each object merged. The objects corresponding to TRUE will have all their times included in

Re: [R] outer join of xts's

2020-01-02 Thread Eric Berger
Hi Gabor, This is great, thanks. It brought the time down to about 4 seconds. The command do.call("merge.xts",L) also works in this case. Suppose that instead of the default "outer" join I wanted to use, say, a "left" join. Is that possible? I tried a few ways of adding the join="left" parameter

Re: [R] outer join of xts's

2020-01-02 Thread Gabor Grothendieck
You don't need Reduce as xts already supports mutliway merges. This perfroms one multiway merge rather than k-1 two way merges. do.call("merge", L) On Thu, Jan 2, 2020 at 6:13 AM Eric Berger wrote: > > Hi, > I have a list L of about 2,600 xts's. > Each xts has a single numeric column.

Re: [R] outer join of xts's

2020-01-02 Thread Enrico Schumann
Quoting Eric Berger : Hi, I have a list L of about 2,600 xts's. Each xts has a single numeric column. About 90% of the xts's have approximately 500 rows, and the rest have fewer than 500 rows. I create a single xts using the command myXts <- Reduce( merge.xts, L ) By default, merge.xts()

[R] outer join of xts's

2020-01-02 Thread Eric Berger
Hi, I have a list L of about 2,600 xts's. Each xts has a single numeric column. About 90% of the xts's have approximately 500 rows, and the rest have fewer than 500 rows. I create a single xts using the command myXts <- Reduce( merge.xts, L ) By default, merge.xts() does an outer join (which is