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.
show_columns(x, columns, col_names)
A condformat object, typically created with condformat()
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.
Character vector with the column names for the selected columns
The condformat object with the rule added
data(iris)
x <- head(iris)
# Include some columns:
cf <- condformat(x) %>% show_columns(c(Sepal.Length, Sepal.Width, Species))
if (FALSE) {
print(cf)
}
cf <- condformat(x) %>% show_columns(c("Sepal.Length", "Sepal.Width", "Species"))
if (FALSE) {
print(cf)
}
# Rename columns:
cf <- condformat(x) %>%
show_columns(c(Sepal.Length, Species),
col_names = c("Length", "Spec."))
if (FALSE) {
print(cf)
}
# Exclude some columns:
cf <- condformat(x) %>% show_columns(c(-Petal.Length, -Petal.Width))
if (FALSE) {
print(cf)
}
cf <- condformat(x) %>% show_columns(c(starts_with("Petal"), Species))
if (FALSE) {
print(cf)
}
petal_width <- "Petal.Width"
cf <- condformat(x) %>% show_columns(!! petal_width)
if (FALSE) {
print(cf)
}