Skip to contents

Verify the integrity of the column info object

Usage

verify_column_info(column_info, data)

Arguments

column_info

A data frame describing which columns in data to plot. This data frame should contain the following columns:

  • id (character): The corresponding column name in data.

  • name (character): A label for the column. If NA or "", no label will be plotted. If this column is missing, id will be used to generate the name column.

  • geom (character): The geom of the column. Must be one of: "funkyrect", "circle", "rect", "bar", "pie", or "text". For "text", the corresponding column in data must be a character. For "pie", the column must be a list of named numeric vectors. For all other geoms, the column must be a numeric.

  • group (character): The grouping id of each column, must match with column_groups$group. If this column is missing or all values are NA, columns are assumed not to be grouped.

  • palette (character): Which palette to colour the geom by. Each value should have a matching value in palettes$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 for geom = "bar").

  • hjust: Horizontal alignment of the label, must be between [0,1] (only for geom = "text").

  • vjust: Vertical alignment of the label, must be between [0,1] (only for geom = "text").

  • size: Size of the label, must be between [0,1] (only for geom = "text").

  • label: Which column to use as a label (only for geom = "text").

  • options (list or json): 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.

data

A data frame with items by row and features in the columns. Must contain one column named "id".

Value

The column info object with all expected columns.

Examples

library(tibble)
data <- tribble(
  ~id, ~name, ~x, ~y,
  "foo", "Foo", 0.5, 0.7,
  "bar", "Bar", 1.0, 0.1
)
column_info <- tribble(
  ~id, ~geom,
  "name", "text",
  "x", "funkyrect",
  "y", "funkyrect"
)
verify_column_info(column_info, data)
#>  Column info did not contain column `name`, using `id` to generate it.
#>  Column info did not contain group information, assuming columns are ungrouped.
#>  Column info did not contain a column called 'palette', generating palettes based on the 'geom' column.
#>  Column info did not contain a column called 'width', generating options based on the 'geom' column.
#>  Column info did not contain a column called 'legend', generating options based on the 'geom' column.
#> # A tibble: 3 × 8
#>   id    geom      name  group palette           width overlay legend
#>   <chr> <chr>     <chr> <chr> <chr>             <dbl> <lgl>   <lgl> 
#> 1 name  text      Name  NA    NA                    6 FALSE   FALSE 
#> 2 x     funkyrect X     NA    numerical_palette     1 FALSE   TRUE  
#> 3 y     funkyrect Y     NA    numerical_palette     1 FALSE   TRUE