Re: [R] permutation/randomization

From: Philipp Pagel <p.pagel_at_wzw.tum.de>
Date: Wed, 09 Apr 2008 22:15:56 +0200

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

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Wed 09 Apr 2008 - 20:22:04 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 09 Apr 2008 - 20:30:40 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive