sampleIn: Sample from/in a design object

Description Usage Arguments Details Value Note See Also Examples

Description

Sample from/in a design object.

Usage

1
sampleIn(X, size = 1L, atSample = FALSE, ...)

Arguments

X

The object, typically a design matrix with class matrix or an object with class "Grid".

size

Number of sample points.

atSample

Logical. If TRUE the new sample points are obtained using sample

...

Other arguments to be passed to the sample function when atSample is TRUE, typically replace = TRUE is needed when the object x contains less than the target number given in size.

Details

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.

Value

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.

Note

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.

See Also

The sample function.

Examples

1
2
3
4
5
6
7
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))

smint documentation built on April 14, 2017, 1:49 p.m.