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

2014-08-01 Thread Stephen HK Wong
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 chr13000215 3000250 - chr13000909

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

2014-08-01 Thread Marc Schwartz
On Aug 1, 2014, at 1:58 PM, Stephen HK Wong hon...@stanford.edu wrote: 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

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

2014-08-01 Thread William Dunlap
Do you know how to extract some rows of a data.frame? A short answer is with subscripts, either integer, first10 - 1:10 dFirst10 - d[first10, ] # I assume your data.frame is called 'd' or logical plus4 - d[, Col_4] == + dPlus4 - d[ plus4, ] If you are not familiar with that sort of