I have a dataframe A with 10,000,000 rows and 5 columns like this one:
SNP REC AF X Y Z
rs1 2.3 0.22 sss ff 472
rs200 4.7 0.7 d tg 634
rs33 30.1 0.5 ddf ap 929
Using R, I'd like to generate 50 new data frames with all columns from A, looping through the first 50 rows in the following way.
For each i,j in columns REC,AF, choose 1000 random rows from A (sampling with replacement) where the following 2 conditions are met:
1) i-2.5 < i < i+2.5 # i = value in REC
2) j-0.05 < j < j+0.05 # j = value in AF
I know how to use the sample function:
A[sample(nrow(A), 1000,replace = TRUE), ]
But I don't know how to automate the function.
Any suggestion will be highly welcome !
Aucun commentaire:
Enregistrer un commentaire