[R] FW: Select a random subset of rows out of matrix

David Winsemius dwinsemius at comcast.net
Mon Mar 16 15:46:53 CET 2009


On Mar 16, 2009, at 10:34 AM, Haenlein.Michael wrote:

> Dear all,
>
> I have a large dataset (N=100,000 with 89 variables per subject).  
> This dataset is stored in a 100.000 x 89 matrix where each row  
> describes one individual and each column one variable.
>
> What is the easiest way of selecting a subset of let's say 1.000  
> individuals out of that whole matrix?


bigmatrix[ sample( 1:nrow(bigmatrix), 1000, replace=FALSE), ]

>
>
> Thanks,
>
> Michael
>
>
> Michael Haenlein
> Associate Professor of Marketing
> ESCP-EAP European School of Management
> Paris, France
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list