[R] computation of matrices in list of list
Benilton Carvalho
bcarvalh at jhsph.edu
Sat Aug 22 23:34:07 CEST 2009
result <- Reduce("+", unlist(z, recursive=FALSE))
b
On Aug 22, 2009, at 2: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
>
>
> 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.
More information about the R-help
mailing list