Skip to contents

Generate a graph showing the contents of a Vector

Usage

paint_vector(
  data,
  layout = c("vertical", "horizontal"),
  show_indices = c("none", "inside", "outside"),
  highlight_area = rep(FALSE, length(data)),
  highlight_color = "lemonchiffon",
  graph_title = paste0("Data Object: ", deparse(substitute(data))),
  graph_subtitle = paste0("Length: ", length(data), " elements | ", "Data Type: ",
    paste(class(data), collapse = ", "))
)

Arguments

data

A object that has the class of vector.

layout

Orientation of the vector. Default: "vertical".

show_indices

Display data indices either: "inside", "outside", or "none" the vector cell, e.g. [i]. Default: "none"

highlight_area

Vector of logical values that provide a mask for what cells should be filled. Default: None.

highlight_color

Color to use to fill the background of a cell.

graph_title

Title to appear in the upper left hand corner of the graph.

graph_subtitle

Subtitle to appear immediately under the graph title in the upper left hand side of the graph.

Examples

# Base graphics

# Visualize a vector with 5 elements
vec_5 <- round(rnorm(5, 0, 4), 2)
paint_vector(vec_5)


# Visualize a 6 element vector with indices underneath data
vec_6 <- c(-3, 5, NA, Inf, 2, 1)
paint_vector(vec_6, layout = "horizontal", show_indices = "inside")


# Highlight the 2nd, 4th, and 6th cell with indices shown outside
paint_vector(
  vec_6, show_indices = "outside", 
  highlight_area = highlight_locations(vec_6, c(2, 4, 6))
)


# Highlight the 4th-6th cells with indices shown inside
paint_vector(
  vec_6, show_indices = "inside", 
  highlight_area = highlight_locations(vec_6, 4:6)
)