Thankyou very much. It worked.
Eliza
From: Bert Gunter
Sent: Friday 15 April 2022 17:00
To: Jeff Newmiller
Cc: R-help ; Eliza Botto
Subject: Re: [R] Sorted index of values in matrix
...
But Ivan's solution -- which I had to think about -- is better
... and here is another version of Jeff's solution using the built in
row() and col() functions instead of explicitly creating the indices
(but his version generalizes to arbitrary arrays; this does not):
qq <- matrix(12:7, nrow =3) ## start with a non-sorted matrix
> qq
[,1] [,2]
[1,] 12
В Fri, 15 Apr 2022 14:53:36 +
Eliza Botto пишет:
> sort(qq) command will execute the sorted values of this matrix as (1
> 2 3 4 5 6). Instead of values, I want the row and column names of
> these sorted values as (1,1), (1,2), (1,3), (2,1), (2,2), (2,3)
Combine order() to get the sorting
deaR useRs,
I have this following simple dataset
> dput(qq)
structure(1:6, .Dim = 3:2, .Dimnames = list(c("1", "2", "3"),
c("1", "2")))
I want to extract row and column index of the sorted values of this matrix
For example,
sort(qq) command will execute the sorted values of this matrix
4 matches
Mail list logo