Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ doc
Meta
compile_commands.json
.cache
*.Rproj
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ Imports:
tibble (>= 3.2.0),
tidyselect (>= 1.2.0),
utils,
vctrs (>= 0.6.4)
vctrs (>= 0.6.4),
palmerpenguins
Suggests:
bench,
broom,
Expand All @@ -56,7 +57,7 @@ Suggests:
stringi (>= 1.7.6),
testthat (>= 3.1.5),
tidyr (>= 1.3.0),
withr
withr,
VignetteBuilder:
knitr
Config/Needs/website: tidyverse, shiny, pkgdown, tidyverse/tidytemplate
Expand Down
29 changes: 20 additions & 9 deletions R/arrange.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,37 @@
#' help page under the `Default locale` section.
#' @family single table verbs
#' @examples
#' arrange(mtcars, cyl, disp)
#' arrange(mtcars, desc(disp))
#' # Load the 'penguins' data set from {palmerpenguins} package (R < 4.5.0)
#' data("penguins")
#'
#' # grouped arrange ignores groups
#' by_cyl <- mtcars %>% group_by(cyl)
#' by_cyl %>% arrange(desc(wt))
#' # Arrange by increasing order of bill depth
#' penguins %>% arrange(bill_depth_mm)
#'
#' # Arrange by increasing order of bill depth and body mass
#' penguins %>% arrange(bill_depth_mm, body_mass_g)
#'
#' # Arrange by increasing order of bill depth and decreasing order of body mass
#' 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