flexible select operator that powers the tidy consultant universe. Used to set sensible defaults and flexibly return the chosen columns. A developer focused function, but may be useful in interactive programming due to the ability to return different types.

select_otherwise(
  .data,
  ...,
  otherwise = NULL,
  col = NULL,
  return_type = c("names", "index", "df")
)

Arguments

.data

dataframe

...

tidyselect. columns to choose

otherwise

tidyselect. default columns to choose if ... is not specified

col

tidyselect. column to choose regardless of ... or otherwise specifications

return_type

choose to return column index, names, or df. defaults to index

Value

integer vector by default. possibly data frame or character vector

Examples


iris %>%
select_otherwise(where(is.double), return_type = "index")
#> Sepal.Length  Sepal.Width Petal.Length  Petal.Width 
#>            1            2            3            4