This function creates a multivariate grid. Each column of the input x is turned (independently) into a vector of grid values via univariate_grid(). Combinations are then formed by calling expand.grid().

multivariate_grid(
  x,
  grid_size = 49L,
  trim = c(0.01, 0.99),
  strategy = c("uniform", "quantile"),
  na.rm = TRUE
)

Arguments

x

A vector, matrix, or data.frame to turn into a grid of values.

grid_size

Controls the approximate grid size. If x has p columns, then each (non-discrete) column will be reduced to about the p-th root of grid_size values.

trim

The default c(0.01, 0.99) means that values outside the 1% and 99% quantiles of non-discrete numeric columns are removed before calculation of grid values. Set to 0:1 for no trimming.

strategy

How to find grid values of non-discrete numeric columns? Either "uniform" or "quantile", see description of univariate_grid().

na.rm

Should missing values be dropped from the grid? Default is TRUE.

Value

A vector, matrix, or data.frame with evaluation points.

Examples

multivariate_grid(iris[1:2], grid_size = 4)
#>   Sepal.Length Sepal.Width
#> 1          4.4         2.2
#> 2          7.7         2.2
#> 3          4.4         4.2
#> 4          7.7         4.2
multivariate_grid(iris$Species)  # Works also in the univariate case
#> [1] setosa     versicolor virginica 
#> Levels: setosa versicolor virginica