makeIwrapper | R Documentation |
The makeIwrapper
function wraps an R function to produce an
iterator constructor. It is used to construct random sampling
iterators in this package; for instance irnorm
is defined as
irnorm <- makeIwrapper(rnorm)
.
makeIwrapper(FUN)
FUN |
a function that generates different values each time it is called; typically one of the standard random number generator functions. |
The resulting iterator constructors all take an optional
count
argument which specifies the number of times the
resulting iterator should fire. They also have an argument
independent
which enables independent tracking of the random
number seed. The isample
function is an example of one such
iterator constructoe (as are irnorm
, irunif
, etc.).
Original version appeared in the iterators
package.
An iterator that is a wrapper around the corresponding function.
# create an iterator maker for the sample function
mysample <- makeIwrapper(sample)
# use this iterator maker to generate an iterator that will generate three five
# member samples from the sequence 1:100
it <- mysample(1:100, 5, count = 3)
nextOr(it)
nextOr(it)
nextOr(it)
nextOr(it, NULL) # NULL
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.