[R] computation of matrices in list of list

David Winsemius dwinsemius at comcast.net
Sat Aug 22 19:17:54 CEST 2009


On Aug 22, 2009, at 1:03 PM, kathie wrote:

>
> Dear Gabor Grothendieck,
>
>
> thank you for your comments.
>
> Ive already tried that. but  I've got this error message.
>
>
>> Reduce("+",z)
> Error in f(init, x[[i]]) : non-numeric argument to binary operator

 > Reduce("+", c( LL[[1]], LL[[2]] ) )
      [,1] [,2] [,3] [,4] [,5]
[1,]    6   36   66   96  126
[2,]   12   42   72  102  132
[3,]   18   48   78  108  138
[4,]   24   54   84  114  144
[5,]   30   60   90  120  150

>
>
> anyway, thanks
>
> ps.
>
>> is.matrix(z[[1]][[1]])
> [1] TRUE
>
> I guess the reason "Reduce" doesn't work is that it has multi- 
> dimentional
> list..
>
>
>
> Gabor Grothendieck wrote:
>>
>> See this:
>>
>> https://stat.ethz.ch/pipermail/r-help/2009-August/208002.html
>>
>> On Sat, Aug 22, 2009 at 11:41 AM, kathie<kathryn.lord2000 at gmail.com>
>> wrote:
>>>
>>> Dear R users,
>>>
>>> I have the list as follows;
>>>
>>> #------------------------------------------------------
>>>
>>>> z
>>>
>>> [[1]]
>>> [[1]][[1]]
>>>
>>> matrix(A)
>>>
>>> [[1]][[2]]
>>>
>>> matrix(B)
>>>
>>> [[1]][[3]]
>>>
>>> matrix(C)
>>>
>>> [[2]]
>>> [[2]][[1]]
>>>
>>> matrix(D)
>>>
>>> [[2]][[2]]
>>>
>>> matrix(E)
>>>
>>> [[2]][[3]]
>>>
>>> matrix(F)
>>>
>>> #---------------------------------------------
>>>
>>> I'd like to compute
>>>
>>> matrix(A)+matrix(B)+matrix(C)+matrix(D)+matrix(E)+matrix(F)
>>>
>>>
>>> In fact, I tried "lapply", "do.call" etc, but failed.
>>>
>>>
>>>
>>> Any suggestion will be greatly appreciated.
>>>
>>> Regards,
>>>
>>> Kathryn Lord
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/computation-of-matrices-in-list-of-list-tp25094875p25094875.html
>>> Sent from the R help mailing list archive at Nabble.com.
>>>
>>> ______________________________________________
>>> 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.
>>>
>>
>> ______________________________________________
>> 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.
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/computation-of-matrices-in-list-of-list-tp25094875p25095627.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list