select_rows: Select rows in a dataframe.

Description Usage Arguments Examples

View source: R/select_rows.r

Description

Select rows in a dataframe.

Usage

1
select_rows(dataframe, rows, whole = FALSE, ..., cols_to_check = NULL)

Arguments

dataframe

a data.frame

rows

an atomic vector or function. Drop all but these rows. If rows is a function, the rows will be selected based on the whole parameter. If whole = TRUE, the whole dataframe will be passed in, and the resulting row indices (character, numeric, or logical) will be selected. If whole = FALSE (the default) the function will be applied to each row and the result will be expected to be a logical, with only the rows returning TRUE being selected.

whole

a logical. See the rows parameter. The default is FALSE.

...

additional arguments to rows is that parameter is a function.

cols_to_check

a character vector. Allows for rows to be applied to a column subset of the dataframe. The default is to apply to all columns of the dataframe.

Examples

1
2
3
4
select_rows(iris, 1:10) # Select only first ten rows
select_rows(iris, c(TRUE,FALSE)) # Select only odd rows
iris2 <- iris; rownames(iris2) <- paste0("row", 1:nrow(iris2))
select_rows(iris, c("row10", "row51")) # Select rows by name

robertzk/syberiaMungebits documentation built on July 30, 2019, 3:37 p.m.