show_columns: Selects the variables to be printed

View source: R/show_columns.R

show_columnsR Documentation

Selects the variables to be printed

Description

Keeps the variables you mention in the printed table. Compared to dplyr::select(), show_columns does not remove the columns from the data frame, so formatting rules can still depend on them.

Usage

show_columns(x, columns, col_names)

Arguments

x

A condformat object, typically created with condformat()

columns

A character vector with column names to be to show. It can also be an expression can be used that will be parsed according to tidyselect::language(). See examples.

col_names

Character vector with the column names for the selected columns

Value

The condformat object with the rule added

See Also

dplyr::select()

Examples


data(iris)
x <- head(iris)

# Include some columns:
cf <- condformat(x) %>% show_columns(c(Sepal.Length, Sepal.Width, Species))
## Not run: 
print(cf)

## End(Not run)
cf <- condformat(x) %>% show_columns(c("Sepal.Length", "Sepal.Width", "Species"))
## Not run: 
print(cf)

## End(Not run)

# Rename columns:
cf <- condformat(x) %>%
  show_columns(c(Sepal.Length, Species),
               col_names = c("Length", "Spec."))
## Not run: 
print(cf)

## End(Not run)

# Exclude some columns:
cf <- condformat(x) %>% show_columns(c(-Petal.Length, -Petal.Width))
## Not run: 
print(cf)

## End(Not run)

cf <- condformat(x) %>% show_columns(c(starts_with("Petal"), Species))
## Not run: 
print(cf)

## End(Not run)

petal_width <- "Petal.Width"
cf <- condformat(x) %>% show_columns(!! petal_width)
## Not run: 
print(cf)

## End(Not run)


condformat documentation built on Oct. 8, 2023, 9:07 a.m.