[R] How to sample database

Loren McCarter lorenmc at socrates.berkeley.edu
Thu Nov 14 00:53:17 CET 2002


In postgresql, one way to take a random sample is using the random()
function with a limit on the number of rows returned. It is something
like:

    select * from mydb
    order by random()
    limit 100;

Perhaps mysql has a similar RANDOM() function that can be used for
sorting by a random field. 

Loren



> Bernardo Rangel Tura <tura at centroin.com.br> writes:
> Subject: Re: [R] How to sample database
> From: Bernardo Rangel Tura <tura at centroin.com.br>
> Cc: r-help at stat.math.ethz.ch
> Date: 13 Nov 2002 19:30:19 +0100
> 
> Dear R-masters!
> 
> I have a database with 2400 patients and I need make a sample with 90 subjects.
> How to I make a random sample in this data base with R?
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list