Skip to contents

Visualize all columns in a data frame with gg1d's vertically aligned plots and automatic plot selection based on variable type. Plots are fully interactive, and custom tooltips can be added.

Usage

gg1d(
  data,
  col_id = NULL,
  col_sort = NULL,
  maxlevels = 6,
  verbose = 2,
  drop_unused_id_levels = FALSE,
  interactive = TRUE,
  debug_return_col_info = FALSE,
  palettes = NULL,
  colours_default = c("#66C2A5", "#FC8D62", "#8DA0CB", "#E78AC3", "#A6D854", "#FFD92F",
    "#E5C494"),
  colours_default_logical = c(`TRUE` = "#648fff", `FALSE` = "#dc267f"),
  colours_missing = "grey90",
  limit_plots = TRUE,
  cols_to_plot = NULL,
  sort_type = c("frequency", "alphabetical"),
  desc = TRUE,
  width = 0.9,
  relative_height_numeric = 4,
  tooltip_column_suffix = "_tooltip",
  ignore_column_regex = "_ignore$",
  show_legend_titles = FALSE,
  show_legend = !interactive,
  legend_position = c("right", "left", "bottom", "top"),
  legend_title_position = c("top", "bottom", "left", "right"),
  legend_title_beautify = TRUE,
  numeric_plot_type = c("bar", "heatmap"),
  legend_nrow = 4,
  legend_ncol = NULL,
  legend_title_size = NULL,
  legend_text_size = NULL,
  legend_key_size = 0.3,
  vertical_spacing = 0,
  na_marker = "!",
  na_marker_size = 8,
  na_marker_colour = "black",
  show_na_marker_categorical = FALSE,
  show_na_marker_heatmap = FALSE,
  show_values_heatmap = TRUE,
  fontsize_y_text = 12,
  y_axis_position = c("left", "right"),
  legend_orientation_heatmap = c("horizontal", "vertical"),
  colours_heatmap_low = "purple",
  colours_heatmap_high = "seagreen",
  transform_heatmap = c("identity", "log10", "log2"),
  fontsize_values_heatmap = 3,
  colours_values_heatmap = "white",
  fontsize_barplot_y_numbers = 8,
  interactive_svg_width = NULL,
  interactive_svg_height = NULL,
  cli_header = "Running gg1d"
)

Arguments

data

data.frame to autoplot (data.frame)

col_id

name of column to use for

col_sort

column to sort sample order by. By default uses the supplied order of levels in col_id (order of appearance if a character type)

maxlevels

for categorical variables, what is the maximum number of distinct values to allow (too many will make it hard to find a palette that suits). (number)

verbose

Numeric value indicating the verbosity level:

  • 2: Highly verbose, all messages.

  • 1: Key messages only.

  • 0: Silent, no messages.

drop_unused_id_levels

if col_id is a factor with unused levels, should these be dropped or included in visualisation

interactive

produce interactive ggiraph visualiastion (flag)

debug_return_col_info

return column info instead of plots. Helpful when debugging (logical)

palettes

A list of named vectors. List names correspond to data column names (categorical only). Vector names to levels of columns. Vector values are colours, the vector names are used to map values in data to a colour.

colours_default

default colours to use for variables. will be used to colour variables with no palette supplied.

colours_default_logical

colours for binary variables (vector of 3 colors where elements represent colours of TRUE, FALSE, and NA respectively) (character)

colours_missing

colour to use for values of NA (string)

limit_plots

throw an error when there are > 15 plottable columns in table (logical)

cols_to_plot

names of columns in data that should be plotted. By default plots all valid columns (character)

sort_type

controls how categorical variables are sorted. Numerical variables are always sorted in numerical order irrespective of the value given here. Options are alphabetical or frequency

desc

sort in descending order (flag)

width

controls how much space is present between bars and tiles within each plot. Can be 0-1 where values of 1 makes bars/tiles take up 100% of available space (no gaps between bars)

relative_height_numeric

how many times taller should numeric plots be relative to categorical tile plots. Only taken into account if numeric_plot_type == "bar" (number)

tooltip_column_suffix

the suffix added to a column name that indicates column should be used as a tooltip (string)

ignore_column_regex

a regex string that, if matches a column name, will cause that column to be exclude from plotting (string) (default: "_ignore$")

show_legend_titles

show legend titles (flag)

show_legend

show the legend (flag)

legend_position

position of the legend on the plot (string, options are "right", "left", "bottom", "top")

legend_title_position

position of the title of the legend on the plot (string, options are "top", "bottom", "left", "right")

legend_title_beautify

beautify legend title (add spaces to snake_case / camelCase & capitalise each word) (flag)

numeric_plot_type

visual representation of numeric properties. One of 'bar', for bar charts, or 'heatmap' for heatmaps.

legend_nrow

the number of rows in the legend (number)

legend_ncol

the number of columns in the legend. Set legend_nrow = NULL when using legend_ncol (number)

legend_title_size

the size of the title of the legend (number)

legend_text_size

the size of the text in the legend (number)

legend_key_size

the size of the key in the legend (number)

vertical_spacing

how large should the gap between each data row be (unit = pt) (number)

na_marker

what text should be added to NA values for numeric variables to indicate the value is NA, not 0 (string)

na_marker_size

how large should the na_marker be (number)

na_marker_colour

colour of the na_marker (string)

show_na_marker_categorical

should a text marker of NA values (e.g. '!') be rendered on tiles with NA values (flag)

show_na_marker_heatmap

should a text marker of NA values (e.g. '!') be rendered on tiles with NA values (flag)

show_values_heatmap

should quantitative values be displayed on heatmap tiles (flag)

fontsize_y_text

size of y axis text (number)

y_axis_position

whether y axis should be on left or right side (either 'left' or 'right')

legend_orientation_heatmap

should legend orientation be "horizontal" or "vertical"

colours_heatmap_low

colour of lowest value in heatmap (string)

colours_heatmap_high

colour of highest value in heatmap (string)

transform_heatmap

transformation to apply to values before heatmap visualisation. one of 'identity' (no transformation), 'log10', or 'log2'

fontsize_values_heatmap

font size of text describing values in heatmap (number)

colours_values_heatmap

colour of text describing values in heatmap (string)

fontsize_barplot_y_numbers

fontsize of the text describing numeric barplot max & min values (number)

interactive_svg_width, interactive_svg_height

width and height of the interactive graphic region (in inches). Only used when interactive = TRUE.

cli_header

Text used for h1 header. Included so it can be tweaked by packages that use gg1d, so they can customise how the info messages appear.

Value

ggiraph interactive visualisation

Examples

path_gg1d <- system.file("example.csv", package = "gg1d")
df <- read.csv(path_gg1d, header = TRUE, na.strings = "")
gg1d(df, col_id = "ID", col_sort = "Glasses")
#> 
#> ── Running gg1d ────────────────────────────────────────────────────────────────
#> ! Categorical columns must have <= 6 unique values to be visualised. Columns with too many unique values: Date (19)
#> 
#> ── Sorting 
#>  Sorting X axis by: Glasses
#>  Order type: frequency
#>  Sort order: descending
#> 
#> ── Generating Plot 
#>  Found 7 plottable columns in data
#>  Plotting column Age
#>  Plotting column Gender
#>  Plotting column EyeColour
#>  Plotting column Height
#>  Plotting column HairColour
#>  Plotting column Glasses
#>  Plotting column WearingHat
#> ! Skipping column WearingHat_tooltip
#> ! Skipping column Date
#>  Stacking plots vertically
#>  Making plot interactive since `interactive = TRUE`