[R] average matrices across a list

Phil Spector spector at stat.berkeley.edu
Sun Sep 12 23:28:28 CEST 2010


Gregory -
    Please provide a reproducible example.
I have no idea what results is.

                                - Phil


On Sun, 12 Sep 2010, Gregory Ryslik wrote:

> Hi,
>
> Doing that I get the following:
>
> Browse[2]> Reduce["+",results]
> Error in Reduce["+", results] :
>  object of type 'closure' is not subsettable
>
> Thanks again!
>
> Kind regards,
> Greg
> On Sep 12, 2010, at 3:49 PM, Phil Spector wrote:
>
>> Gregory -
>>   Suppose your list is called "mymats".  Then
>>
>> Reduce("+",mymats)
>>
>> does what you want.
>>                                  - Phil
>>
>>
>> On Sun, 12 Sep 2010, Gregory Ryslik wrote:
>>
>>> Hi,
>>>
>>> I have a list of several hundred 2 dimensional matrices, where each matrix is n x m. What I need to do is that for each n,m I  need an average over all the lists. This would collapse it down to just one nxm matrix. Any easy ways to do that? As always, I'd like to avoid a for loop to keep computational time low! Thanks again everyone!
>>>
>>> Cheers,
>>> G
>>> ______________________________________________
>>> 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.
>



More information about the R-help mailing list