Re: [R] Running a function through a vector with the scalars as arguments

2009-06-17 Thread Bill.Venables
8 June 2009 10:17 To: Economics Guy Cc: r-help@r-project.org Subject: Re: [R] Running a function through a vector with the scalars as arguments Try this: sapply(theProbs, rbinom, size = 1, n = 1) You are using probsFoo in lapply, I don't know what is this. On Wed, Jun 17, 2009

Re: [R] Running a function through a vector with the scalars as arguments

2009-06-17 Thread Henrique Dallazuanna
Try this: sapply(theProbs, rbinom, size = 1, n = 1) You are using probsFoo in lapply, I don't know what is this. On Wed, Jun 17, 2009 at 9:09 PM, Economics Guy wrote: > I have a vector of probabilities that I would like to feed to rbinom() > and have it return a 1 or 0 for each element. I have

[R] Running a function through a vector with the scalars as arguments

2009-06-17 Thread Economics Guy
I have a vector of probabilities that I would like to feed to rbinom() and have it return a 1 or 0 for each element. I have tried simply using the entire vector as the argument hoping R would understand. Instead I get a scalar: theProbs <- runif(10,0,1) youreON <- rbinom(1, 1, theProbs) Next I