Skip to content
Prev 296197 / 398503 Next

Probably a good use for apply

Hi,
On Thu, May 31, 2012 at 1:08 PM, LCOG1 <jroll at lcog.org> wrote:
Your first problem is that sampleWorker() doesn't run with a single
component of test_ so it can't possibly run in an apply statement.

Please reread ?sample - the second argument is the size of the desired
sample, but what you are passing is a non-integer vector of length 2.
What do you actually want this to be?

Then for prob, you're passing c(x, 1-x)) but x is again a non-integer
vector of length 2, so that results in a vector of length 4, which is
longer than the number of options sample() is choosing from.

Do you perhaps want to pass only a single probability at a time? But
even then you need to resolve the size problem.

Sarah