Learn R Programming

clinUtils (version 0.1.4)

getLinetypePalette: 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
)

Value

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

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.

Author

Laure Cougnaud and Michela Pasetto

Details

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

Examples

Run this code
# 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"))

Run the code above in your browser using DataLab