getLinetypePalette: Get a linetype palette for clinical visualizations.

View source: R/plots-palettes.R

getLinetypePaletteR Documentation

Get a linetype palette for clinical visualizations.

Description

Get a linetype palette of specified length, either from a vector of names for the palette, or from a specified length.

Usage

getLinetypePalette(
  n = NULL,
  x = NULL,
  includeNA = FALSE,
  palette = clinLinetypes
)

Arguments

n

Integer of length 1, number of elements in palette.

x

Vector with elements used for palette. If factor, the levels are used, otherwise the unique elements of the vector. Missing values are automatically removed, excepted if includeNA is set to TRUE.

includeNA

Logical (FALSE by default), should NA elements be retained in the palette in case x is specified?

palette

A vector of custom linetypes, or a function returning this vector from a specific number of linetypes.
Default is the clinLinetypes linetype palette.

Details

Note that 7 unique symbols are available at maximum (replicated if necessary).

Value

Vector with linetypes, named with the elements in x if x is specified.

Author(s)

Laure Cougnaud and Michela Pasetto

Examples

# extract longest linetype palette available
getLinetypePalette(n = 6)
# extract palette for a vector
getLinetypePalette(x = paste('treatment', 1:4))
# include missing
getLinetypePalette(x = c(NA_character_, "group1"), includeNA = TRUE)
getLinetypePalette(x = c(NA_character_, "group1"), includeNA = FALSE)
# set custom linetypes
lty <- getColorPalette(n = 3, palette = c("twodash", "dashed"))

clinUtils documentation built on Jan. 6, 2023, 5:29 p.m.