mutate_text: Add a quick tooltip text column to data.

Description Usage Arguments Value Examples

View source: R/mutate_text.R

Description

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

Usage

1
2
3
4
5
mutate_text(
  data,
  vars_vctr = NULL,
  numeric_format = function(x) prettyNum(x, big.mark = "", scientific = FALSE)
)

Arguments

data

A tibble or dataframe. Required input.

vars_vctr

A vector of quoted variables to include in the tooltip. Defaults to NULL, which adds all variables in.

numeric_format

A function to format all numeric variables within the tooltip text column. Defaults to non-scientific. Use function(x) x to leave as is.

Value

A tibble or data frame with an additional column called text.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
library(simplevis)
library(dplyr)

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

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

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

simplevis documentation built on Jan. 15, 2022, 1:08 a.m.