Skip to contents

These functions assign or retrieve a "show_only" attribute for a vector (typically a column in a dataframe). The attribute specifies which levels should be displayed while keeping the full dataset intact.

Usage

set_show_only(x, levels)

get_show_only(x)

Arguments

x

A vector (typically a column from a dataframe) to which the "show_only" attribute should be assigned or from which it should be extracted.

levels

(For set_show_only() only) A character vector specifying the levels to be included in the "show_only" attribute.

Value

For set_show_only, the modified vector with the "show_only" attribute set. For get_show_only, the "show_only" attribute value.

Examples

library(dplyr)

example_df <- data.frame(region = c("North", "South", "East", "West"))

get_show_only(example_df$region) # Returns: NULL
#> NULL

example_df <- example_df %>%
  mutate(region = set_show_only(region, c("North", "South")))

get_show_only(example_df$region) # Returns: "North" "South"
#> [1] "North" "South"