From: Czerminski, Ryszard (ryszard@arqule.com)
Date: Wed 26 Jun 2002 - 22:38:20 EST
Message-id: <EDE2901A3801144496F3485FCFEC8D3027C4BA@EPOCH.arqule.com>
Great idea ! I am sure it would be very useful - in particular
to the newcomers to the R-land.
The question is where to put it and how to organize it
to make it useful ?
Some database approach with web interface would be probably good
in the long run.
R
Ryszard Czerminski phone: (781)994-0479
ArQule, Inc. email:ryszard@arqule.com
19 Presidential Way http://www.arqule.com
Woburn, MA 01801 fax: (781)994-0679
-----Original Message-----
From: Robin Hankin [mailto:r.hankin@auckland.ac.nz]
Sent: Wednesday, June 26, 2002 12:52 AM
To: r-help@stat.math.ethz.ch
Subject: [R] sapply() and Monte Carlo
Dear Helplist
Some time ago, Professor Ripley gave me a tip which I thought was very
very useful for Monte Carlo simulation; I thought I'd pass it on to
the list, and ask whether this or a similar example could be added to
the sapply() manpage.
Suppose I have ten N(0,1) random variables and I'm interested in the
pair that are closest together:
R> min(diff(sort(rnorm(10))))
[1] 0.04438955
To generate a PDF for this statistic one can use sapply() as follows:
R> func <- function(n){min(diff(sort(rnorm(n))))}
R> hist(sapply(rep(10,999),func),col="gray")
This is *soooo* much better than having a loop! Cheers everyone!
Anyone got any other interesting uses of sapply()? Would anyone on
the List be interested in a collection specifically of neat R
oneliners?
--Robin Hankin, Lecturer, School of Geographical and Environmental Science Private Bag 92019 Auckland New Zealand
r.hankin@auckland.ac.nz tel 0064-9-373-7599 x6820; FAX 0064-9-373-7042 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. -.- 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@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@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
This archive was generated by hypermail 2.1.3 : Wed 16 Oct 2002 - 11:57:33 EST