I have question about how to generate random numbers for each .txt file generated by write.table
command. I want to write different rows of random numbers to each .txt file.
ref_file <- data.frame(id=seq(1:10)) #
This creates 10 output file with random samples
lapply(seq_along(ref_file$id), function(i) write.table(sample(10,replace=F),paste0(ref_file$id[i],'.txt'), quote=FALSE, col.names = FALSE,row.names=FALSE))
My question is how to put different number of rows for each .txt file.
For example 1.txt
contains 3 rows of sample numbers but 10.txt
can contain 6 random sample numbers.
Thanks in advance!