[R] How to randomize a set of integers in R

Liaw, Andy andy_liaw at merck.com
Thu Aug 19 16:19:28 CEST 2004


Use sample() in either case:

## randomly shuffle the elements of the vector `x':
rx <- sample(x, replace=FALSE)

## randomly draw 6800 integers between 1 and 6800:
x <- sample(6800, 6800, replace=TRUE)

Andy

> From: Olaf Mersmann
> 
> Hi Susanne,
> * Susanne Osterkamp <sokamp at web.de> [040819 15:52]:
> > Hello,
> > 
> > I want  to validate my data for working with CART.
> > I need to now how to create a randomized column of some 6800 intgers
> > within R. 
> 
> Do you want to sample 6800 random integers? In that case try ?runif
> (for uniform distribution) 
> 
> If you want to resample 6800 integers try ?sample
> 
> HTH
> Olaf Mersmann
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
>




More information about the R-help mailing list