Delete specific rows from a data frame or matrix
stm_delete_rows.Rd
stm_delete_rows()
deletes the specified rows from a data frame or
matrix based on the provided indices.
Details
This function uses stm_transform_keep_delete()
to remove the rows
specified in indices
. The result can optionally be returned as a
matrix based on the as_matrix
argument.
Examples
A <- matrix(1:15, ncol = 3, byrow = TRUE)
print(A)
#> [,1] [,2] [,3]
#> [1,] 1 2 3
#> [2,] 4 5 6
#> [3,] 7 8 9
#> [4,] 10 11 12
#> [5,] 13 14 15
stm_delete_rows(A, 2)
#> [,1] [,2] [,3]
#> [1,] 1 2 3
#> [2,] 7 8 9
#> [3,] 10 11 12
#> [4,] 13 14 15
stm_delete_rows(A, c(1, 3))
#> [,1] [,2] [,3]
#> [1,] 4 5 6
#> [2,] 10 11 12
#> [3,] 13 14 15