Re: [R] Loop with random sampling and write.table

2011-09-03 Thread Jorge I Velez
Hi Pete Pete, Try # option 1 -- 100 files sapply(1:100, function(i){ x <-sample(rnorm(1000, 100, 15), 12, replace = FALSE) write.table(x, paste("sample", i, ".txt", sep = ""), row.names = FALSE, quote = FALSE)) }) # option 2 -- all the information in one file d <- replicate(100, sample(rnorm(1

[R] Loop with random sampling and write.table

2011-09-03 Thread Pete Pete
Hi! I need to perform this simple sampling function several hundred times: x1=as.character(rnorm(1000, 100, 15)) x2=as.character(rnorm(1000, 150, 10)) y1=as.data.frame(x1,x2) sample1=as.data.frame(sample(y1$x1, 12, replace = FALSE, prob = NULL)) sample1 write.table(sample1, "sample1.txt", sep="