xy_grid | R Documentation |
Create a Cartesian product from evenly spaced values of two variables.
xy_grid(x, ...) ## Default S3 method: xy_grid(x, y, grid.resolution = 51, col.names = NULL, ...) ## S3 method for class 'formula' xy_grid(x, data, grid.resolution = 51, ...) ## S3 method for class 'matrix' xy_grid(x, grid.resolution = 51, ...) ## S3 method for class 'data.frame' xy_grid(x, grid.resolution = 51, ...)
x |
Either a numeric vector (if argument |
... |
Additional (optional) arguments. (Currently ignored.) |
y |
A numeric vector representing the second variable (only required if
|
grid.resolution |
Integer specifying the number of equally-spaced values
to use for each numeric variable. For example, if |
col.names |
Optional vector of column names to use for the output
whenever both |
data |
A data frame containing the variables specified in
|
formula |
A two-variable formula of the form |
A data frame representing the Cartesian product between equally spaced values from each variable.
x1 <- 1:3 x2 <- letters[1L:3L] xy_grid(x1, x2, gr = 3, col.names = c("x1", "x2")) # will have 3^2=9 rows xy_grid(m <- cbind(x1, x2), gr = 3) # equivalent xy_grid(d <- as.data.frame(m), gr = 3) # equivalent xy_grid(x2 ~ x1, data = d, gr = 3) # equivalent
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.