Create a data frame from all combinations of the supplied vectors or factors. See the description of the return value for precise details of the way this is done.
expand.grid(…, KEEP.OUT.ATTRS = TRUE, stringsAsFactors = TRUE)
| Parameter | Description |
|---|---|
… |
vectors, factors or a list containing these. |
KEEP.OUT.ATTRS |
a logical indicating the "out.attrs" attribute (see below) should be computed and returned. |
stringsAsFactors |
logical specifying if character vectors are converted to factors. |
# NOT RUN {
require(utils)
expand.grid(height = seq(60, 80, 5), weight = seq(100, 300, 50),
sex = c("Male","Female"))
x <- seq(0, 10, length.out = 100)
y <- seq(-1, 1, length.out = 20)
d1 <- expand.grid(x = x, y = y)
d2 <- expand.grid(x = x, y = y, KEEP.OUT.ATTRS = FALSE)
object.size(d1) - object.size(d2)
##-> 5992 or 8832 (on 32- / 64-bit platform)
# }