Well, kinda that's what I'm looking for.  I was just hoping to assign a random number to a variable and write a function around that to determine the coin toss...something like:

r = some random number
if r modulus 2 = 0 then heads
else tails
repeat...


...buy your little one line ditty will do more than well enough!  Thanks.  I'm new to R and statistics in general...got this little workbook/textbook type of thing here.  One of the questions is "write a computer program that simulates the flipping of a coin n times"

Thanks again,

Joshua Gramlich
Chicago, IL




----- Original Message ----- 
From: "J.R. Lockwood" <lockwood@rand.org>
To: "Joshua Gramlich" <jgramlich@piocon.com>
Cc: "J.R. Lockwood" <lockwood@rand.org>
Sent: Thursday, January 02, 2003 4:02 PM
Subject: Re: [R] random number generation


> what do you mean by single?
> dichotomous?
> 
> if so then
> sample(c(0,1),size=100,replace=T)
> 
> will get you 100 tosses of a fair coin.
> 
> you can change the probabilities with the "prob" argument.
> 
> also you can expand c(0,1) to any number of outcomes.
> 
> On Thu, 2 Jan 2003, Joshua Gramlich wrote:
> 
> > Date: Thu, 2 Jan 2003 15:58:35 -0600
> > From: Joshua Gramlich <jgramlich@piocon.com>
> > To: r-help@stat.math.ethz.ch
> > 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
> > 
> > ______________________________________________
> > R-help@stat.math.ethz.ch mailing list
> > http://www.stat.math.ethz.ch/mailman/listinfo/r-help
> > 
> 
> J.R. Lockwood
> 412-683-2300 x4941
> lockwood@rand.org
> http://www.rand.org/methodology/stat/members/lockwood/
	[[alternate HTML version deleted]]


