Many ways of doing this. Try rbinom(n=1, size=1, prob=0.5) and you can adjust the 'prob' argument if you have an unfair coin. The other one is sample( c(0,1), 1 ) which is a sampling method and also has a 'prob' argument. Other functions include rnorm, runif, rpois ....
-----Original Message----- From: Joshua Gramlich [mailto:[EMAIL PROTECTED]] Sent: Friday, January 03, 2003 5:59 AM To: [EMAIL PROTECTED] Subject: [R] random number generation Can a single random number be generated in R? I have an exercise that wants to simulate coin tosses, and I cannot seem to find a good example of the use of random number generation in R. Any help? Joshua Gramlich Chicago, IL ______________________________________________ [EMAIL PROTECTED] mailing list http://www.stat.math.ethz.ch/mailman/listinfo/r-help ______________________________________________ [EMAIL PROTECTED] mailing list http://www.stat.math.ethz.ch/mailman/listinfo/r-help
