[R] choosing a random sample by precentage

Nordlund, Dan (DSHS/RDA) NordlDJ at dshs.wa.gov
Fri Jul 23 01:09:41 CEST 2010


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Xebar Saram
> Sent: Thursday, July 22, 2010 3:50 PM
> To: r-help at r-project.org
> Subject: [R] choosing a random sample by precentage
> 
> hi all
> 
> i have found the follwoing way to choose a random sample by sample size
> (200):
> 
> ten_per_T2000 <- F_T2000_All[sample(nrow(F_T2000_All), 200), ]
> 
> 
>  but i wondered if there is a way to choose a sample size by
> precentage (10% etc..)
> 
> thx
> 
> ethan
> 


Maybe something like:

>ten_per_T2000 <- F_T2000_All[sample(nrow(F_T2000_All), 0.1*nrow(F_T2000_All)), ]


Hope this is helpful,

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204




More information about the R-help mailing list