[R] cbind for list of zoo objects

Joshua Ulrich josh.m.ulrich at gmail.com
Tue Apr 9 01:23:23 CEST 2013


Because 'all' is the name of one of the arguments to cbind.zoo:

R> args(cbind.zoo)
function (..., all = TRUE, fill = NA, suffixes = NULL, drop = FALSE)
NULL

do.call constructs a call somewhat like:
R> cbind(test=zz$test, all=zz$all, foo=zz$foo)

The same thing would happen for list elements named 'fill',
'suffixes', or 'drop'.

Best,
--
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com

R/Finance 2013: Applied Finance with R  | www.RinFinance.com


On Mon, Apr 8, 2013 at 2:54 PM, Harry Mamaysky <h.mamaysky at gmail.com> wrote:
>  Can someone explain why this happens when one of the list elements is named 'all'?
>
>> zz <- list( zoo(1:10,1:10), zoo(101:110,1:10), zoo(201:210,1:10) )
>> names(zz)<-c('test','bar','foo')
>> do.call(cbind,zz)
>    test bar foo
> 1     1 101 201
> 2     2 102 202
> 3     3 103 203
> 4     4 104 204
> 5     5 105 205
> 6     6 106 206
> 7     7 107 207
> 8     8 108 208
> 9     9 109 209
> 10   10 110 210
>> names(zz)<-c('test','all','foo')
>> do.call(cbind,zz)
>    test foo
> 1     1 201
> 2     2 202
> 3     3 203
> 4     4 204
> 5     5 205
> 6     6 206
> 7     7 207
> 8     8 208
> 9     9 209
> 10   10 210
>>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> 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