spider_web: Make a spider web plot

Description Usage Arguments Examples

View source: R/plot.R

Description

Make a spider web plot

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
spider_web(
  df,
  grp_col = "nm",
  spk_col = "spk",
  value_col = "value",
  spoke_color = "grey75",
  spoke_lty = 1,
  ref_lines_val = c(0.5, 0.75, 1),
  ref_lines_color = rep("grey75", length(ref_lines_val)),
  ref_lines_type = rep(1, length(ref_lines_val)),
  ref_label_color = rep("grey50", length(ref_lines_val)),
  ref_lines_label_spoke = c(length(unique(df[, spk_col, drop = TRUE])),
    length(unique(df[, spk_col, drop = TRUE])), 0),
  diff_lty_by_name = "ref",
  diff_lty = 2,
  lwd = 1,
  palette = "Set2",
  show_legend = TRUE,
  leg_main_title = "Legend",
  leg_lty_title = "Linetype",
  return_data = FALSE
)

Arguments

df

A data.frame representing groups and spokes for the plot (see examples)

grp_col

The name of the column used for groups

spk_col

The name of the column used for spokes

value_col

The name of the column used for the values of each group along the spokes

spoke_color

Single value for color of the spokes

spoke_lty

Single integer value for the line type of the spokes

ref_lines_val

A vector of reference line values to plot

ref_lines_color

A vector of reference line colors

ref_lines_type

vector of reference line types

ref_label_color

A vector of reference label colors

ref_lines_label_spoke

A vector of reference label locations (spoke number). A value of zero means that the label will not be printed

diff_lty_by_name

This is an optional string which will be used to grep() the names of the values given in column grp_col. If they match, the diff_lty value will be used for line type for those lines

diff_lty

Line type to use for grp_col values that diff_lty_by_name matches with grep()

lwd

Line width for the main coloured lines.

palette

As defined in ggplot2::scale_color_brewer()

show_legend

Show legend?

leg_main_title

Main legend title

leg_lty_title

Linetype legend title

return_data

Logical? Return the data instead of the plot?

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
df <- data.frame(
  nm = c(
    "A", "B", "C",
    "A", "B", "C",
    "A", "B", "C",
    "A", "B", "C",
    "A", "B", "C"
  ),
  spk = c(
    "P1", "P1", "P1",
    "P2", "P2", "P2",
    "P3", "P3", "P3",
    "P4", "P4", "P4",
    "P5", "P5", "P5"
  ),
  value = c(
    .1, .2, .3,
    .4, .5, .6,
    .7, .8, .9,
    .10, .11, .12,
    .13, .14, .15
  )
)
spider_web(df,
  ref_lines_label_spoke = c(4, 3, 0),
  ref_lines_type = c(2, 3, 4),
  ref_lines_color = c("black", "royalblue", "salmon")
)

pbs-assess/ggspider documentation built on Dec. 29, 2020, 6:07 a.m.