Bert Gunter wrote:
>
> Serves me right, I suppose. Timing seems also very dependent on the
> dimensions of the matrix. Here's what I got with my inadequate test:
>
>
>> x <- matrix(rnorm(3e5),ncol=3)
>>
> ## via apply
>
>> system.time(apply(x,1,max))
>>
>user system elapsed
Sent: Monday, March 30, 2009 2:33 AM
To: Rolf Turner
Cc: Bert Gunter; 'Ana M Aparicio Carrasco'; r-help@r-project.org
Subject: Re: [R] Matrix max by row
Rolf Turner wrote:
> I tried the following:
>
> m <- matrix(runif(10),1000,100)
> junk <- gc()
> print(system.t
>>
>> Hint:The man page for ?data.frame says:
>> "A data frame is a list of variables of the same length with unique row
>> names, given class 'data.frame'."
>>
>> Cheers,
>> Bert
>>
>> Bert Gunter
>> Genentech Nonclinica
essage-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Rolf Turner
Sent: Monday, 30 March 2009 1:39 PM
To: Bert Gunter
Cc: 'Wacek Kusnierczyk'; r-help@r-project.org
Subject: Re: [R] Matrix max by row
I tried the following:
m <- matrix(runif
project.org] On
Behalf Of Wacek Kusnierczyk
Sent: Saturday, March 28, 2009 5:22 PM
To: Ana M Aparicio Carrasco
Cc: r-help@r-project.org
Subject: Re: [R] Matrix max by row
Ana M Aparicio Carrasco wrote:
I need help about how to obtain the max by row in a matrix.
For example if I have the follow
Of Wacek Kusnierczyk
Sent: Saturday, March 28, 2009 5:22 PM
To: Ana M Aparicio Carrasco
Cc: r-help@r-project.org
Subject: Re: [R] Matrix max by row
Ana M Aparicio Carrasco wrote:
> I need help about how to obtain the max by row in a matrix.
> For example if I have the following matrix:
> 2 5
?apply
> x <- rbind(c(2,5,3),c(8,7,2),c(1,8,4))
> apply(x, 1, max)
[1] 5 8 8
>
>
On Sat, Mar 28, 2009 at 7:54 PM, Ana M Aparicio Carrasco
wrote:
> I need help about how to obtain the max by row in a matrix.
> For example if I have the following matrix:
> 2 5 3
> 8 7 2
> 1 8 4
>
> The max by row
Ana M Aparicio Carrasco wrote:
> I need help about how to obtain the max by row in a matrix.
> For example if I have the following matrix:
> 2 5 3
> 8 7 2
> 1 8 4
>
> The max by row will be:
> 5
> 8
> 8
>
matrix(apply(m, 1, max), nrow(m))
vQ
__
R-he
I need help about how to obtain the max by row in a matrix.
For example if I have the following matrix:
2 5 3
8 7 2
1 8 4
The max by row will be:
5
8
8
Thank you.
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https:
9 matches
Mail list logo