stm_delete_cols()
removes specified columns from a data frame.
It uses stm_transform_keep_delete()
to perform the operation.
Usage
stm_delete_cols(dat, indices, as_matrix = TRUE)
Arguments
- dat
A data frame or matrix from which columns will be removed.
- indices
A numeric vector or logical vector indicating the columns
to delete.
- as_matrix
Optional. A logical value indicating whether the result
should be returned as a matrix. Default is TRUE
.
Value
A data frame or matrix with the specified columns removed.
Details
This function uses stm_transform_keep_delete()
to remove the specified
columns from the given data. If as_matrix
is TRUE
, the result
is returned as a matrix, otherwise a data frame is returned.
Examples
A <- matrix(1:15, ncol = 5, byrow = TRUE)
print(A)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 1 2 3 4 5
#> [2,] 6 7 8 9 10
#> [3,] 11 12 13 14 15
stm_delete_cols(A, 2)
#> [,1] [,2] [,3] [,4]
#> [1,] 1 3 4 5
#> [2,] 6 8 9 10
#> [3,] 11 13 14 15