Skip to contents

where_shrthnd_cols() applies is_shrthnd_num() across columns of a data.frame (or elements in a list). which_shrthnd_cols() identifies the columns in a data.frame or (elements of a list) by name or index position. any_shrthnd_cols() tests whether a data.frame (or list) has any columns that are shrthnd_num() vectors.

Usage

where_shrthnd_cols(x)

which_shrthnd_cols(x, .names = FALSE)

any_shrthnd_cols(x)

Arguments

x

A data.frame (or list)

.names

A logical vector indicating whether to return column names or an integer vector of column positions (the default)

Value

For where_shrthnd_cols() a logical vector of the same length as the number columns in x. For which_shrthnd_cols() a character vector of names or an integer vector of index positions (the default). For any_shrthnd_cols() either TRUE if there are any shrthnd_num()

vectors in the object or FALSE if not.

See also

Examples

x <- c("12", "34.567", "[c]", "NA", "56.78[e]", "78.9", "90.123[e]")
sh_x <- shrthnd_num(x, c("[c]", "[e]"))
tbl <- tibble::tibble(x = x, sh_x = sh_x)

where_shrthnd_cols(tbl)
#> [1] FALSE  TRUE

which_shrthnd_cols(tbl)
#> [1] 2

which_shrthnd_cols(tbl, .names = TRUE)
#> [1] "sh_x"

any_shrthnd_cols(tbl)
#> [1] TRUE