Learn R Programming

nplyr (version 0.2.0)

nest_arrange: Arrange rows within a nested data frames by column values

Description

nest_arrange() orders the rows of nested data frames by the values of selected columns.

Usage

nest_arrange(.data, .nest_data, ..., .by_group = FALSE)

Value

An object of the same type as .data. Each object in the column .nest_data

will be also of the same type as the input. Each object in .nest_data has the following properties:

  • All rows appear in the output, but (usually) in a different place.

  • Columns are not modified.

  • Groups are not modified.

  • Data frame attributes are preserved.

Arguments

.data

A data frame, data frame extension (e.g., a tibble), or a lazy data frame (e.g., from dbplyr or dtplyr).

.nest_data

A list-column containing data frames

...

Variables, or functions of variables. Use dplyr::desc() to sort a variable in descending order.

.by_group

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

Details

nest_arrange() is largely a wrapper for dplyr::arrange() and maintains the functionality of arrange() within each nested data frame. For more information on arrange(), please refer to the documentation in dplyr.

See Also

Other single table verbs: nest_filter(), nest_mutate(), nest_rename(), nest_select(), nest_slice(), nest_summarise()

Examples

Run this code
gm_nest <- gapminder::gapminder %>% tidyr::nest(country_data = -continent)

gm_nest %>% 
  nest_arrange(country_data, pop)

gm_nest %>%
  nest_arrange(country_data, desc(pop))

Run the code above in your browser using DataLab