Verify the integrity of the column groups object
Source:R/verify_column_groups.R
verify_column_groups.RdVerify the integrity of the column groups object
Arguments
- column_groups
A data frame describing of how to group the columns in
column_info. Can consist of the following columns:group(character): The corresponding group incolumn_info$group.palette(character, optional): The palette used to colour the column group backgrounds.level1(character): The label at the highest level.level2(character, optional): The label at the middle level.level3(character, optional): The label at the lowest level (not recommended).
- column_info
A data frame describing which columns in
datato plot. This data frame should contain the following columns:id(character, required): A column name indatato plot. Determines the size of the resulting geoms, and also the color unlesscoloris specified.id_color(character): A column name indatato use for the color of the resulting geoms. IfNA, theidcolumn will be used.id_size(character): A column name indatato use for the size of the resulting geoms. IfNA, theidcolumn will be used.name(character): A label for the column. IfNAor"", no label will be plotted. If this column is missing,idwill be used to generate thenamecolumn.geom(character): The geom of the column. Must be one of:"funkyrect","circle","rect","bar","pie","text"or"image". For"text", the corresponding column indatamust be acharacter. For"pie", the column must be a list of named numeric vectors. For all other geoms, the column must be anumeric.group(character): The grouping id of each column, must match withcolumn_groups$group. If this column is missing or all values areNA, columns are assumed not to be grouped.palette(character): Which palette to colour the geom by. Each value should have a matching value inpalettes$palette.width: Custom width for this column (default: 1).overlay: Whether to overlay this column over the previous column. If so, the width of that column will be inherited.legend: Whether or not to add a legend for this column.hjust: Horizontal alignment of the bar, must be between [0,1] (only forgeom = "bar").vjust: Vertical alignment of the label, must be between [0,1] (only forgeom = "text").size: Size of the label, must be a numeric value (only forgeom = "text").label: Which column to use as a label (only forgeom = "text").directory: Which directory to use to find the images (only forgeom = "image").extension: The extension of the images (only forgeom = "image").draw_outline: Whether or not to draw bounding guides (only forgeom == "bar"). Default:TRUE.options(listorjson): Any of the options above. Any values in this column will be spread across the other columns. This is useful for not having to provide a data frame with 1000s of columns. This column can be a json string.
Examples
library(tibble)
column_groups <- tribble(
~group, ~level1,
"foo", "Foo",
"bar", "Bar"
)
column_info <- tribble(
~id, ~geom, ~group,
"name", "text", NA_character_,
"foo1", "funkyrect", "foo",
"foo2", "funkyrect", "foo",
"bar1", "funkyrect", "bar",
"bar2", "funkyrect", "bar"
)
verify_column_groups(column_groups, column_info)
#> ℹ Column groups did not contain a column called 'palette'. Assuming no colour scales need to be used.
#> # A tibble: 2 × 3
#> group level1 palette
#> <chr> <chr> <chr>
#> 1 foo Foo NA
#> 2 bar Bar NA