Skip to contents

This function filters a dataframe or a survey design object by removing specified rows based on the provided row numbers. The resulting filtered dataframe is returned, along with the tidyverse code used to generate it.

Usage

remove_rows(data, rows)

Arguments

data

A dataframe or a survey design object to be filtered.

rows

A numeric vector of row numbers to be sliced off.

Value

A filtered dataframe with the tidyverse code attached.

See also

Author

Owen Jin, Zhaoming Su

Examples

data <- remove_rows(iris, rows = c(1, 4, 5))
cat(code(data))
#> dplyr::slice(iris, -(c(1, 4, 5)))
head(data)
#>   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1          4.9         3.0          1.4         0.2  setosa
#> 2          4.7         3.2          1.3         0.2  setosa
#> 3          5.4         3.9          1.7         0.4  setosa
#> 4          4.6         3.4          1.4         0.3  setosa
#> 5          5.0         3.4          1.5         0.2  setosa
#> 6          4.4         2.9          1.4         0.2  setosa