human: Interactive Human Body Widget

View source: R/human.R

humanR Documentation

Interactive Human Body Widget

Description

This widget visualizes an SVG-based human body, highlights specific body parts, and displays associated participant data.

Usage

human(
  gender = c("male", "female"),
  organ_df,
  select_color = "yellow",
  width = NULL,
  height = NULL,
  elementId = NULL
)

Arguments

gender

One of "male" or "female"

organ_df

A data.frame with at least an organ column, and optionally the following columns:

  • show: A logical (Boolean) column indicating whether or not each organ should be visible. If absent, all organs will be shown.

  • selected: A logical (Boolean) column indicating whether or not each organ should be in a "selected" state. If absent, no organs will be selected.

  • hovertext: A character column or a column containing shiny.tag objects. This will be the contents of the tooltip that appears when the organ is hovered over. If absent, the tooltip will contain the title-cased name of the organ (underscores replaced with spaces).

  • color: A character column indicating the color of the organ. If absent, all organs will be shown in black. If organ_df has other columns, these will be ignored.

select_color

The color that should be applied to organs with the "selected" state (activated by clicking the organ and deactivated by clicking again).

width

Widget width

height

Widget height

elementId

ID of the widget

Value

An object of class human and class htmlwidget.

Examples

example_organs <- c("brain", "eye", "heart", "stomach", "bladder")
my_organ_df <- subset(shinybody_organs, organ %in% example_organs)
my_organ_df$show <- TRUE
my_organ_df$color <- grDevices::rainbow(nrow(my_organ_df))
my_organ_df$selected[1] <- TRUE
my_organ_df$hovertext <- mapply(
  function(o, clr) htmltools::strong(
    tools::toTitleCase(o),
    style = paste("color:", clr)
  ),
  my_organ_df$organ,
  my_organ_df$color,
  SIMPLIFY = FALSE
)
human(gender = "female", organ_df = my_organ_df)

shinybody documentation built on April 4, 2025, 3:28 a.m.