getShapePalette {clinUtils}R Documentation

Get a shape palette for clinical visualizations.

Description

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

Usage

getShapePalette(
  n = NULL,
  x = NULL,
  includeNA = FALSE,
  asText = FALSE,
  palette = if (asText) {
     clinShapesText
 } else {
     clinShapes
 }
)

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?

asText

Logical (FALSE by default), should the palette be expressed as integer (base R plot and ggplot2 compatible) or in text format (e.g. required if combined with unicode symbols in ggplot2)?

palette

A vector of custom shapes, or a function returning this vector from a specific number of shapes.
The vector should be a character if asText is set to TRUE.
Default is the clinShapes shape palette, or clinShapesText if asText is set to TRUE.

Details

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

Value

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

Author(s)

Laure Cougnaud and Michela Pasetto

Examples

#' extract longest shape palette available
getShapePalette(n = 19)
# extract palette for a vector
getShapePalette(x = paste('treatment', 1:4))
# include missing
getShapePalette(x = c(NA_character_, "group1"), includeNA = TRUE)
getShapePalette(x = c(NA_character_, "group1"), includeNA = FALSE)
# change default settings
getShapePalette(x = paste('treatment', 1:3), palette = c("circle", "triangle"))
# get symbols as 'text' (e.g. to be combined with Unicode in ggplot2)
getShapePalette(x = paste('treatment', 1:4), asText = TRUE)

[Package clinUtils version 0.2.0 Index]