Skip to content

These are methods for the dplyr dplyr::select(), dplyr::rename(), and dplyr::relocate() generics. They generate the SELECT clause of the SQL query.

These functions do not support predicate functions, i.e. you can not use where(is.numeric) to select all numeric variables.

Usage

# S3 method for class 'tbl_lazy'
select(.data, ...)

# S3 method for class 'tbl_lazy'
rename(.data, ...)

# S3 method for class 'tbl_lazy'
rename_with(.data, .fn, .cols = everything(), ...)

# S3 method for class 'tbl_lazy'
relocate(.data, ..., .before = NULL, .after = NULL)

Arguments

.data

A lazy data frame backed by a database query.

...

<data-masking> Variables, or functions of variables. Use desc() to sort a variable in descending order.

.fn

A function used to transform the selected .cols. Should return a character vector the same length as the input.

.cols

<tidy-select> Columns to rename; defaults to all columns.

.before, .after

<tidy-select> Destination of columns selected by .... Supplying neither will move columns to the left-hand side; specifying both is an error.

Examples

library(dplyr, warn.conflicts = FALSE)

db <- memdb_frame(x = 1, y = 2, z = 3)
db %>% select(-y) %>% show_query()
#> <SQL>
#> SELECT `x`, `z`
#> FROM `dbplyr_POYIe2ufx9`
db %>% relocate(z) %>% show_query()
#> <SQL>
#> SELECT `z`, `x`, `y`
#> FROM `dbplyr_POYIe2ufx9`
db %>% rename(first = x, last = z) %>% show_query()
#> <SQL>
#> SELECT `x` AS `first`, `y`, `z` AS `last`
#> FROM `dbplyr_POYIe2ufx9`