Re: [R] biasing conditional sample

2012-11-11 Thread dms
ate Professor of Anthropology > Texas A&M University > College Station, TX 77843-4352 > >> -Original Message- >> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- >> project.org] On Behalf Of Rui Barradas >> Sent: Sunday, November 11, 201

Re: [R] biasing conditional sample

2012-11-11 Thread David L Carlson
PM > To: d...@riseup.net > Cc: r-help@r-project.org > Subject: Re: [R] biasing conditional sample > > Hello, > > The function that follows returns a matrix, not a data.frame but does > what you ask for. > > > fun <- function(x, y, n){ > f <- f

Re: [R] biasing conditional sample

2012-11-11 Thread arun
Hi, If the question is to remove the duplicates/repeated in each row from the example "data", then dat2<-data[apply(data,1,function(x) all(!duplicated(x)|duplicated(x,fromLast=TRUE))),] head(dat2) #   id a b  c d  e #6   6 9 5 10 1  7 #8   8 5 2  6 7  4 #11 11 6 4  9 8  5 #12 12 7 1  8 9 10 #15

Re: [R] biasing conditional sample

2012-11-11 Thread Rui Barradas
Hello, The function that follows returns a matrix, not a data.frame but does what you ask for. fun <- function(x, y, n){ f <- function(x, y){ while(TRUE){ rnd <- sample(x, 1) if(!any(rnd %in% y)) break } rnd } for(i in seq_len(n)){