Learn R Programming

simplevis (version 2.0.0)

add_tip: Add a quick tooltip text column to data.

Description

Add a column of tooltip text which is automatically created based on column names and values.

Usage

add_tip(data, vars_vctr, comma = FALSE)

Arguments

data

A tibble or dataframe. Required input.

vars_vctr

A vector of quoted variables to include in the tooltip. Required input.

comma

TRUE or FALSE of whether to convert numeric values to character values with comma seperators.

Value

A vector of labels.

Examples

Run this code
# NOT RUN {
library(dplyr)

plot_data <- slice_sample(ggplot2::diamonds, prop = 0.05) %>% 
  add_tip(vars_vctr = c("carat", "price"), comma = TRUE)

plot <- ggplot_scatter(data = plot_data, x_var = carat, y_var = price,
                       tip_var = tip_text,
                       title = "Diamond price by carat",
                       x_title = "Carat",
                       y_title = "Price ($US thousands)")

plotly::ggplotly(plot, tooltip = "text")
# }

Run the code above in your browser using DataLab