Re: [R] Matrix summary

2016-02-12 Thread Jim Lemon
Hi Ashta,
Surely you are aware of the "apply" family of functions that return the
numbers you want:

ashmat<-matrix(c(117,12,13,21,21,32,11,1,65,43,23,7,58,61,78,95 ),
 nrow=4,byrow=TRUE)
apply(ashmat,2,mean)
[1] 65.25 37.00 31.25 31.00
apply(ashmat,1,which.max)
[1] 1 2 1 4

Jim


On Sat, Feb 13, 2016 at 3:04 PM, Ashta  wrote:

> hi all,
>
> I have  a square matrix (1000 by 1000),
> 1. I want calculate  mean,  min and max values for each column and row.
>
> 2, I want pick the  coordinate value of the matrix that has the max
> and min value for each row and column.
> This an example 4 by 4 square matrix
>
>
>   MeanMinMax
> 117   1213 2140.75   12117
>  213211   1 16.25   1   32
>  654323   7  34.57   65
>  586178 957358  95
> Mean652537   31.25
> Min2112111
> Max 117617895
>
>
> Thank you
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] Matrix summary

2016-02-12 Thread Bert Gunter
Yes, but colMeans, rowMeans, pmax, pmin , etc. are *much* faster.

Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Fri, Feb 12, 2016 at 9:15 PM, Jim Lemon  wrote:
> Hi Ashta,
> Surely you are aware of the "apply" family of functions that return the
> numbers you want:
>
> ashmat<-matrix(c(117,12,13,21,21,32,11,1,65,43,23,7,58,61,78,95 ),
>  nrow=4,byrow=TRUE)
> apply(ashmat,2,mean)
> [1] 65.25 37.00 31.25 31.00
> apply(ashmat,1,which.max)
> [1] 1 2 1 4
>
> Jim
>
>
> On Sat, Feb 13, 2016 at 3:04 PM, Ashta  wrote:
>
>> hi all,
>>
>> I have  a square matrix (1000 by 1000),
>> 1. I want calculate  mean,  min and max values for each column and row.
>>
>> 2, I want pick the  coordinate value of the matrix that has the max
>> and min value for each row and column.
>> This an example 4 by 4 square matrix
>>
>>
>>   MeanMinMax
>> 117   1213 2140.75   12117
>>  213211   1 16.25   1   32
>>  654323   7  34.57   65
>>  586178 957358  95
>> Mean652537   31.25
>> Min2112111
>> Max 117617895
>>
>>
>> Thank you
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Matrix summary

2016-02-12 Thread Ashta
hi all,

I have  a square matrix (1000 by 1000),
1. I want calculate  mean,  min and max values for each column and row.

2, I want pick the  coordinate value of the matrix that has the max
and min value for each row and column.
This an example 4 by 4 square matrix


  MeanMinMax
117   1213 2140.75   12117
 213211   1 16.25   1   32
 654323   7  34.57   65
 586178 957358  95
Mean652537   31.25
Min2112111
Max 117617895


Thank you

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.