Hi all, Is there an R function to generate random integers? Thanks in advance. Sincerely Anup --------------------------------- Now that's room service! Choose from over 150,000 hotels [[alternative HTML version deleted]]
> Is there an R function to generate random integers? Thanks in advance.For example, if you want 5 random integers from the sequence 1:50, you can do the following: sample(1:50,5) Paul
On 25 Feb 2007, at 06:51, Anup Nandialath wrote:> > Is there an R function to generate random integers? Thanks in > advance.The package Random does what you want, but requires a net connection. http://cran.r-project.org/src/contrib/Descriptions/random.html "This package provides an interface to the true random number service provided by the random.org website created by Mads Haahr. The random.org web service samples atmospheric noise via radio tuned to an unused broadcasting frequency together with a skew correction algorithm due to John von Neumann." install.packages("random") library(random) ?random > randomNumbers(10,1,6,1) V1 1 5 2 3 3 6 4 3 5 3 6 1 7 6 8 4 9 5 10 3 Andy -- Andy Fugard, Postgraduate Research Student Psychology (Room F15), The University of Edinburgh, 7 George Square, Edinburgh EH8 9JZ, UK Mobile: +44 (0)78 123 87190 http://www.possibly.me.uk
Sure. rpois(n, lambda) ... will do it. But you should tell us something about how you want your numbers to be distributed, since rpois() produces integers having a Poisson distribution. Charles Annis, P.E. Charles.Annis at StatisticalEngineering.com phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Anup Nandialath Sent: Sunday, February 25, 2007 1:51 AM To: r-help at stat.math.ethz.ch Subject: [R] Random Integers Hi all, Is there an R function to generate random integers? Thanks in advance. Sincerely Anup --------------------------------- Now that's room service! Choose from over 150,000 hotels [[alternative HTML version deleted]] ______________________________________________ R-help at stat.math.ethz.ch 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.