Create a matrix for input or output variables that can be used in DEA models
from a supplied data.frame
Usage
create_matrix(df, columns, id, normalize = FALSE)
Arguments
- df
A data.frame containing the data.
- columns
A character vector of column names to include in the matrix.
- id
A character string specifying the column with DMU IDs.
- normalize
A logical indicating whether to normalize the columns by their
mean. Defaults to FALSE
.
Value
A matrix of inputs or outputs
Examples
df <- data.frame(id = 1:3, a = c(10, 20, 30), b = c(5, 15, 25))
create_matrix(df, columns = c("a", "b"), id = "id", normalize = TRUE)
#> a b
#> 1 0.5 0.3333333
#> 2 1.0 1.0000000
#> 3 1.5 1.6666667