[R] how to randomize data matrix
Spencer Graves
spencer.graves at pdf.com
Thu Aug 28 22:20:43 CEST 2003
>A <- array(1:16, dim=c(4,4))
dimnames(A) <- list(LETTERS[1:4], letters[1:4])
A[sample(1:4), ]
> A <- array(1:16, dim=c(4,4))
> dimnames(A) <- list(LETTERS[1:4], letters[1:4])
> A[sample(1:4), ]
a b c d
C 3 7 11 15
B 2 6 10 14
D 4 8 12 16
A 1 5 9 13
>
hope this helps. spencer graves
szhan at uoguelph.ca wrote:
> Dear R users:
> Is there a function or easier way to randomize the data between rows
> (considering a row as a whole unit)? For example,
> original data:
> A1 A2 A3 A4
> B1 1 2 3 4
> B2 5 6 7 8
> B3 9 10 11 12
> B4 13 14 15 16
> randomized data:
> A1 A2 A3 A4
> B4 13 14 15 16
> B2 5 6 7 8
> B1 1 2 3 4
> B3 9 10 11 12
> Thank you for your attention!
> Joshua
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
More information about the R-help
mailing list