Dear Sohail,
df1[ sample(1:dim(df1)[1]), ]
does that,
Best wishes,
Mario
At 10:48 AM 7/26/2005 -0400, Khan, Sohail wrote:
Dear List,
Is there a way to "shuffle" a data frame based on a column. I.E. if the
data frame looks like:
pos ratio
1 0.2356
2 0.5236
3 1.2356
4 2.5690
I would like to randomly shuffle based on column pos so data frame looks like:
pos ratio
3 1.2356
1 0.2356
4 2.5690
2 0.5236
I would really appreciate your help. Thanks.
Sohail Khan
Scientific Programmer
COLD SPRING HARBOR LABORATORY
Genome Research Center
500 Sunnyside Boulevard
Woodbury, NY 11797
(516)422-4076
--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu. To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message: unsubscribe s-news
_______________________
Dr Mario Cortina Borja
Senior Lecturer in Statistics
M.Cortina@ich.ucl.ac.uk Phone +44(0)20 7905 2113 Fax +44(0)20 7905 2381
Paed. Epid. & Biostats, Institute of Child Health, UCL, London WC1N 1EH, UK
|