[R] Problem with sample function

2012-06-08 Thread Guido Leoni
Dear list Is there a way to extract a random sample without duplicated row from a dataframe ?. a=c(1,2,3,1,1,1,2,1) b=c(1,2,3,1,2,1,2,1) c=c(1,1,1,1,1,1,1,1) d=c(1,2,3,1,1,1,2,1) prov-data.frame(a,b,c,d) prov2-prov[sample(1:nrow(prov),5,replace=T),] prov2 a b c d 3 3 3 1 3 6 1 1 1 1

Re: [R] Problem with sample function

2012-06-08 Thread Özgür Asar
Dear Guido, Try prov2-prov[sample(1:nrow(prov),5,replace=F),] which corresponds to without replacement sampling. Best Ozgur -- View this message in context: http://r.789695.n4.nabble.com/Problem-with-sample-function-tp4632835p4632836.html Sent from the R help mailing list archive at

Re: [R] Problem with sample function

2012-06-08 Thread David Winsemius
On Jun 8, 2012, at 12:33 PM, Guido Leoni wrote: Dear list Is there a way to extract a random sample without duplicated row from a dataframe ?. a=c(1,2,3,1,1,1,2,1) b=c(1,2,3,1,2,1,2,1) c=c(1,1,1,1,1,1,1,1) d=c(1,2,3,1,1,1,2,1) prov-data.frame(a,b,c,d)

Re: [R] Problem with sample function

2012-06-08 Thread Guido Leoni
yes you are right it was my inattention it is friday and my head needs to start the week end sorry;-) 2012/6/8 David Winsemius dwinsem...@comcast.net On Jun 8, 2012, at 12:33 PM, Guido Leoni wrote: Dear list Is there a way to extract a random sample without duplicated row from a