Hi, I want to pick 3 "integer" random numbers from 1 to 10. How to do this? Thanks, Yu-Ling Wu __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Yu-Ling Wu wrote:> > Hi, > > I want to pick 3 "integer" random numbers from 1 to > 10. How to do this?Please read the docs. In this case have a look at ?runif Uwe Ligges -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Wednesday 21 March 2001 02:15, Yu-Ling Wu wrote:> Hi, > > I want to pick 3 "integer" random numbers from 1 to > 10. How to do this?as.integer(runif(3)*10+1) Cheers Kaspar Pflugshaupt -- Kaspar Pflugshaupt Geobotanical Institute ETH Zurich, Switzerland http://www.geobot.umnw.ethz.ch mailto:pflugshaupt at geobot.umnw.ethz.ch -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
| -----Original Message----- | From: Kaspar Pflugshaupt [mailto:pflugshaupt at cirsium.ethz.ch] | Sent: Wednesday, 21 March 2001 17:32 | To: Yu-Ling Wu | Cc: r-help mailing list | Subject: Re: [R] generate random number | | | On Wednesday 21 March 2001 02:15, Yu-Ling Wu wrote: | > Hi, | > | > I want to pick 3 "integer" random numbers from 1 to | > 10. How to do this? | | as.integer(runif(3)*10+1) Eh? There is a simpler way: sample(1:10, 3) sample(1:10, 3, rep=T) depending on what is meant. The second is equivalent to yours. | | Cheers | | Kaspar Pflugshaupt | | | -- | | | Kaspar Pflugshaupt | Geobotanical Institute | ETH Zurich, Switzerland | | http://www.geobot.umnw.ethz.ch | mailto:pflugshaupt at geobot.umnw.ethz.ch | -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. | -.-.-.-.-.-.-.-.- | 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 | _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._. | _._._._._._._._._ | -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>>>>> On Wed, 21 Mar 2001 08:31:52 +0100, >>>>> Kaspar Pflugshaupt (KP) wrote:> On Wednesday 21 March 2001 02:15, Yu-Ling Wu wrote: >> Hi, >> >> I want to pick 3 "integer" random numbers from 1 to >> 10. How to do this? > as.integer(runif(3)*10+1) better : sample(1:10, size=3, replace=TRUE) [because also working on general vectors, not only integers, as e.g., sample(letters, size=3, replace=TRUE) ] -- ------------------------------------------------------------------- Friedrich Leisch Institut f?r Statistik Tel: (+43 1) 58801 10715 Technische Universit?t Wien Fax: (+43 1) 58801 10798 Wiedner Hauptstra?e 8-10/1071 Friedrich.Leisch at ci.tuwien.ac.at A-1040 Wien, Austria http://www.ci.tuwien.ac.at/~leisch ------------------------------------------------------------------- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> I want to pick 3 "integer" random numbers from 1 to > 10. How to do this?If you mean sampling without replacement: sample(1:10,3,replace=FALSE) If you mean with replacement: sample(1:10,3,replace=TRUE) Bill -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._