[R] How to randomly extract a number of rows in a data frame

Stephen HK Wong honkit at stanford.edu
Fri Aug 1 20:58:10 CEST 2014


Dear ALL,

I have a dataframe contains 4 columns and several 10 millions of rows like below! I want to extract out "randomly" say 1 millions of rows, can you tell me how to do that in R using base packages? Many Thanks!!!!

Col_1	Col_2	Col_3	Col_4
chr1	3000215	3000250	-
chr1	3000909	3000944	+
chr1	3001025	3001060	+
chr1	3001547	3001582	+
chr1	3002254	3002289	+
chr1	3002324	3002359	-
chr1	3002833	3002868	-
chr1	3004565	3004600	-
chr1	3004945	3004980	+
chr1	3004974	3005009	-
chr1	3005115	3005150	+
chr1	3005124	3005159	+
chr1	3005240	3005275	-
chr1	3005558	3005593	-
chr1	3005890	3005925	+
chr1	3005929	3005964	+
chr1	3005913	3005948	-
chr1	3005913	3005948	-

Stephen HK Wong



More information about the R-help mailing list