sampleIn | R Documentation |
Sample from/in a design object.
sampleIn(X, size = 1L, atSample = FALSE, ...)
## S4 method for signature 'matrix'
sampleIn(X, size = 1L, atSample = FALSE, ...)
## S4 method for signature 'data.frame'
sampleIn(X, size = 1L, atSample = FALSE, ...)
## S4 method for signature 'Grid'
sampleIn(X, size = 1L, atSample = FALSE, ...)
X |
design Grid |
size |
Number of sample points. |
atSample |
should new sample points obtained using |
... |
optional args passed to 'sample()' |
From the object, size
'new' design points are sampled or
drawn. When atSample
is FALSE
, the range of each
column is computed or extracted from the object x
, and then
independent drawings from the corresponding uniform distributions
are used.
A matrix with size
rows. When atSample
is
TRUE
, the matrix has an attribute named index
which
gives the position of the sampled items in the original grid.
When x
is of class "Grid"
, it may be the case
that the drawings with atSample = FALSE
have no meaning since some
of the variables may be discrete variables and not continuous ones.
The sample
function.
g <- Grid(levels = list("Temp" = c(400, 450, 500),
"Bore" = c(0, 600, 1200, 1800, 2400)))
X1 <- sampleIn(g, size = 4)
X2 <- sampleIn(g, size = 4, atSample = TRUE)
## this must be zero
sum(abs(as.matrix(g)[attr(X2, "index"), ] - X2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.