Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Imports:
lifecycle (>= 1.0.3),
magrittr (>= 1.5),
methods,
palmerpenguins,
pillar (>= 1.9.0),
R6,
rlang (>= 1.1.3),
Expand Down
26 changes: 17 additions & 9 deletions R/arrange.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,34 @@
#' help page under the `Default locale` section.
#' @family single table verbs
#' @examples
#' arrange(mtcars, cyl, disp)
#' arrange(mtcars, desc(disp))
#' data("penguins", package = "palmerpenguins")
#'
#' # grouped arrange ignores groups
#' by_cyl <- mtcars %>% group_by(cyl)
#' by_cyl %>% arrange(desc(wt))
#' # Arrange by increasing order
#' penguins %>% arrange(bill_depth_mm)
#' penguins %>% arrange(bill_depth_mm, body_mass_g)
#'
#' # Mix sorting by increasing and decreasing order
#' penguins %>% arrange(bill_depth_mm, desc(body_mass_g))
#'
#' # Grouped arrange ignores groups
#' by_species <- penguins %>% group_by(species)
#' by_species %>% arrange(desc(flipper_length_mm))

#' # Unless you specifically ask:
#' by_cyl %>% arrange(desc(wt), .by_group = TRUE)
#' by_species %>% arrange(desc(flipper_length_mm), .by_group = TRUE)
#'
#' # use embracing when wrapping in a function;
#' # see ?rlang::args_data_masking for more details
#' tidy_eval_arrange <- function(.data, var) {
#' .data %>%
#' arrange({{ var }})
#' }
#' tidy_eval_arrange(mtcars, mpg)
#' tidy_eval_arrange(penguins, bill_length_mm)
#'
#' # Use `across()` or `pick()` to select columns with tidy-select
#' iris %>% arrange(pick(starts_with("Sepal")))
#' iris %>% arrange(across(starts_with("Sepal"), desc))
#' penguins %>% arrange(pick(contains("depth")))
#' penguins %>% arrange(across(ends_with("mm"), desc))
#'
arrange <- function(.data, ..., .by_group = FALSE) {
UseMethod("arrange")
}
Expand Down
1 change: 1 addition & 0 deletions dplyr.Rproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Version: 1.0
ProjectId: 0223743b-bfb8-4b54-bb6c-1b278ea360c9

RestoreWorkspace: Default
SaveWorkspace: Default
Expand Down
28 changes: 19 additions & 9 deletions man/arrange.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading