dbplyr (version 1.4.2)

arrange.tbl_lazy: Arrange rows by variables in a remote database table

Description

Order rows of database tables by an expression involving its variables.

Usage

# S3 method for tbl_lazy
arrange(.data, ..., .by_group = FALSE)

Arguments

.data

A tbl. All main verbs are S3 generics and provide methods for tbl_df(), dtplyr::tbl_dt() and dbplyr::tbl_dbi().

...

Comma separated list of unquoted variable names, or expressions involving variable names. Use desc() to sort a variable in descending order.

.by_group

If TRUE, will sort first by grouping variable. Applies to grouped data frames only.

Value

An object of the same class as .data.

Missing values

Compared to its sorting behaviour on local data, the arrange() method for most database tables sorts NA at the beginning unless wrapped with desc(). Users can override this behaviour by explicitly sorting on is.na(x).

Examples

Run this code
# NOT RUN {
library(dplyr)

dbplyr::memdb_frame(a = c(3, 4, 1, 2)) %>%
  arrange(a)

# NA sorted first
dbplyr::memdb_frame(a = c(3, 4, NA, 2)) %>%
  arrange(a)

# override by sorting on is.na() first
dbplyr::memdb_frame(a = c(3, 4, NA, 2)) %>%
  arrange(is.na(a), a)

# }

Run the code above in your browser using DataCamp Workspace