[R] Permutation of Matrix
David Winsemius
dwinsemius at comcast.net
Tue Apr 6 00:25:56 CEST 2010
On Apr 5, 2010, at 4:58 PM, Ayush Raman wrote:
> Hi all,
>
> How can I have a permuted matrix where the second row is the
> permutation
> over the first row ; third is the permutation of the second row;
> forth is
> the permutation of the third row and so on ?
Wouldn't any of those permutations just be a permutation of the first
row? Perhaps something like:
M <- matrix(first_row, length(first_row), length(first_row))
M[1, ] <- first_row
M[2:length(first_row), ] <- rbind(
t(sapply(2:length(first_row), function(x) {
sample(first_row, length(first_row),
replace=FALSE) }
) )
)
--
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list