[R] Randomly selecting rows with unique values in two columns

R. Michael Weylandt <michael.weylandt@gmail.com> michael.weylandt at gmail.com
Tue Sep 27 02:52:51 CEST 2011


It sounds like you've already done the hard(er) part: just use sample(nrow, noWanted) now to pick which rows to select. 

Michael Weylandt

On Sep 26, 2011, at 5:42 PM, hasan <halhaddad at ucdavis.edu> wrote:

> Hello,
> 
> I am trying to randomly select rows with unique values in columns 1 and 2. I
> want to generate multiple subsets to estimate a statistic for each data set.
> Below is a simplified example.
> 
>   L1 L2 L3 L4 L5
> 1   a  b  1  2  3
> 2   a  c  4  5  6
> 3   a  d  7  8  9
> 4   a  e 10 11 12
> 5   a  f 13 14 15
> 6   b  c 16 17 18
> 7   b  d 19 20 21
> 8   b  e 22 23 24
> 9   b  f 25 26 27
> 10  c  d 28 29 30
> 11  c  e 31 32 33
> 12  c  f 34 35 36
> 13  d  e 37 38 39
> 14  d  f 40 41 42
> 15  e  f 43 44 45
> 
> Could you please give directions to where to start? I have tried eliminating
> duplicates and finding unique rows but no successful to make it random.
> 
> Thanks
> 
> Hasan
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/Randomly-selecting-rows-with-unique-values-in-two-columns-tp3845504p3845504.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> 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.



More information about the R-help mailing list