Displaying 1 result from an estimated 1 matches for "probsfoo".
2009 Jun 18
1
Running a function through a vector with the scalars as arguments
...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 tried using the apply function but I could not get that to work either:
youreON2 <- lapply(probsFoo,rbinom, n=1, size=1, prob=theProbs))
I normally would just write a loop to run down the vector and spit out
the new vector but I am trying to learn to live without loops. Is
there any way to make this work with some flavor of apply?