On Thu, 2007-12-06 at 09:45 -0800, mogra wrote:
> I have huge data file, and I would like randomize just one column at a time ,
> is there any easy way?
> 
> Thanks a lot.

If you just want to randomly <hint> sample <\hint> from a single column,
_independent of the other columns_, you can use:

  DF$Column[sample(nrow(DF))]

where DF$Column is the column of interest in your data frame 'DF'.

If you want to randomly sample entire rows from 'DF', you can use:

  DF[sample(nrow(DF)), ]

See ?sample for more information.

HTH,

Marc Schwartz

______________________________________________
R-help@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.

Reply via email to