These are methods for the dplyr select()
, rename()
, and 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.
# 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)
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.
A function used to transform the selected .cols
. Should
return a character vector the same length as the input.
<tidy-select
> Columns to rename;
defaults to all columns.
<tidy-select
> Destination of
columns selected by ...
. Supplying neither will move columns to the
left-hand side; specifying both is an error.
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_A18VI8wNwu`
db %>% relocate(z) %>% show_query()
#> <SQL>
#> SELECT `z`, `x`, `y`
#> FROM `dbplyr_A18VI8wNwu`
db %>% rename(first = x, last = z) %>% show_query()
#> <SQL>
#> SELECT `x` AS `first`, `y`, `z` AS `last`
#> FROM `dbplyr_A18VI8wNwu`