Hi, Using ur code: dat1<- read.table(text="A B 5 257 259 10 257 259 10.1 257 259 4 257 259 9 257 259 2 257 259 8 257 259 1 257 259 8.1 257 259 8.2 257 259 7 255 257",sep="",header=TRUE)
set.seed(49) res<-sapply(dat1,function(x) as.vector(replicate(500,x[sample(seq_along(x),length(x),replace=TRUE)]))) dim(res) #[1] 5500 2 A.K. ----- Original Message ----- From: Rosario Garcia Gil <m.rosario.gar...@slu.se> To: "r-help@r-project.org" <r-help@r-project.org> Cc: Sent: Wednesday, September 11, 2013 6:20 AM Subject: [R] resample from data frame: unlinked columns Hello I am trying to resample from this data set (see below). The function I am using so far is doing it by considering A and B columns as linked. I used this function. >NUCh_rep<-replicate(500,data[sample(1:nrow(data),replace=T),],simplify=F) What I need is to resample (500 times) with replacement but considering A and B columns UNLINKED. Any advice it is most appreciated. Thanks. A B 5 257 259 10 257 259 10.1 257 259 4 257 259 9 257 259 2 257 259 8 257 259 1 257 259 8.1 257 259 8.2 257 259 7 255 257 [[alternative HTML version deleted]] ______________________________________________ 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. ______________________________________________ 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.