
Prepares a data frame for printing by selecting columns and applying specific transformations.
Source:R/printable.R
printable.RdThis function works like dplyr::select to pick columns from a data frame.
Additionally, character or factor columns are truncated to name_width if they
represent protein or gene identifiers, and to text_width otherwise.
Arguments
- .data
A data frame.
- ...
Columns to select, passed to
dplyr::select(). If empty, all columns are selected.- names_width
The width to which the "Protein Group" and other name columns will be truncated.
- text_width
The width to which the other textual columns (notes, descriptions) will be truncated.
- overview_width
The width to which the data overview text will be truncated.
Examples
# Example data frame
df <- data.frame(
protein_group = "Long Protein Group Name Example String",
gene_names = "Long Gene Names Example String",
protein_names = paste(rep("LongProteinName", 5), collapse = ";"),
`Other Column` = "Some other value",
`Numeric Column` = 12345.678,
check.names = FALSE
)
# Selects "Protein Group" and "Gene Names", truncates both.
printable(df, protein_group, gene_names, names_width = 20)
#> protein_group gene_names
#> 1 Long Protein Grou... Long Gene Names E...
# Renames "Protein Group" to PG. "PG" (originating from "Protein Group")
# and "Gene Names" will be truncated.
printable(df, PG = protein_group, gene_names, names_width = 20)
#> PG gene_names
#> 1 Long Protein Group Name Example String Long Gene Names E...
# Selects all columns if no arguments are given, truncates applicable ones.
printable(df, names_width = 20)
#> protein_group gene_names protein_names
#> 1 Long Protein Grou... Long Gene Names E... LongProteinName;L...
#> Other Column Numeric Column
#> 1 Some other value 12345.68
# Selects "Numeric Column", no truncation applies as it's not a target name.
printable(df, `Numeric Column`, names_width = 20)
#> Numeric Column
#> 1 12345.68