Skip to contents

The union tree of select_variables(): complete linkage on 1 - the largest |Spearman rho| over all data sets, so variables joined below the dashed line (|rho| >= thr_r) are collinear in at least one data set; these clusters are shaded alternately. Below the tree, each row is one variable set and the dots mark its variables: a passing set takes at most one variable from each cluster. By default the rows are the best-ranked sets of each size (largest size first), labelled with their size and rank, and the variables of the first row are printed in bold.

Usage

plot_variable_tree(
  x,
  set = NULL,
  n_sets = 2,
  base_size = 11,
  file = NULL,
  width = 2550,
  height = 1950
)

Arguments

x

A var_selection.

set

Sets to show as rows: NULL (default) = the n_sets best-ranked sets of each size; one set as a character vector of variable names; or several sets, each one string with names separated by spaces (as in best_sets()), optionally named to label the rows.

n_sets

Number of best sets per size shown when set is NULL (at most 10 rows in total).

base_size

Base font size.

file

Optional file(s) to save the plot to, e.g. "fig.pdf" or c("fig.png", "fig.pdf"); the format follows the extension, and a name without extension is saved as PNG and PDF. The plot is also returned.

width, height

Size of the saved figure in pixels (PDF and SVG at 300 pixels per inch).

Value

A ggplot object.

Examples

# see ?select_variables; e.g. plot_variable_tree(vs), or with your own
# choice next to the best set:
# plot_variable_tree(vs, c(best = best_sets(vs)$set[1],
#                          mine = "bio05 bio15 bio17"))