[R] permutation/randomization
Philipp Pagel
p.pagel at wzw.tum.de
Wed Apr 9 22:15:56 CEST 2008
On Wed, Apr 09, 2008 at 11:08:28AM -0700, Grant Gillis wrote:
> I would like to randomize data within columns.
I think the following line does what you want (minus preserving the row
labels):
apply(data, 2, sample)
Maybe someone smarter than me knows how to preserve the row names. I
would probably just steal them from the original data frame:
nam = row.names(data)
apply(data, 2, sample)
row.names(foo) = nam
cu
Philipp
--
Dr. Philipp Pagel Tel. +49-8161-71 2131
Lehrstuhl für Genomorientierte Bioinformatik Fax. +49-8161-71 2186
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
http://mips.gsf.de/staff/pagel
More information about the R-help
mailing list