all_rows | R Documentation |
Subset data rows
all_rows()
filter_rows(..., .by = NULL)
max_rows(order_by, n, by = NULL, with_ties = TRUE, na_rm = FALSE)
min_rows(order_by, n, by = NULL, with_ties = TRUE, na_rm = FALSE)
first_rows(n, by = NULL)
last_rows(n, by = NULL)
sample_rows(n, by = NULL)
... |
< |
.by , by |
< |
order_by |
< |
n |
The number of rows to select. If not are supplied, A negative value of |
with_ties |
Should ties be kept together? The default, |
na_rm |
Should missing values in |
A function
to achieve the desired data subsetting.
# Highlight all animals
animals |>
tidyplot(x = weight, y = size) |>
add_data_points() |>
add_data_points(data = all_rows(),
color = "red", shape = 1, size = 3)
# Highlight 3 animals with the highest weight
animals |>
tidyplot(x = weight, y = size) |>
add_data_points() |>
add_data_points(data = max_rows(weight, n = 3),
color = "red", shape = 1, size = 3)
# Highlight 3 animals with the lowest weight
animals |>
tidyplot(x = weight, y = size) |>
add_data_points() |>
add_data_points(data = min_rows(weight, n = 3),
color = "red", shape = 1, size = 3)
# Highlight the first 3 animals in the dataset
animals |>
tidyplot(x = weight, y = size) |>
add_data_points() |>
add_data_points(data = first_rows(n = 3),
color = "red", shape = 1, size = 3)
# Highlight the last 3 animals in the dataset
animals |>
tidyplot(x = weight, y = size) |>
add_data_points() |>
add_data_points(data = last_rows(n = 3),
color = "red", shape = 1, size = 3)
# Highlight 3 random animals
animals |>
tidyplot(x = weight, y = size) |>
add_data_points() |>
add_data_points(data = sample_rows(n = 3),
color = "red", shape = 1, size = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.