formula_to_sym: Turn a formula into a symbol

Description Usage Arguments Details Examples

View source: R/functions.R

Description

Turn a formula into a symbol

Usage

1

Arguments

x

a formula that would be passed to plotly functions. #'

Details

Turn a formula object (as used in plotly functions for column names) into a symbol object (as used in dplyr functions for column names).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# Useful for converting between plotly code and dplyr code
data <- data.frame(
 group = "A"
 x = 1:100,
 y = rnorm(100)
)

x_plot <- ~x
y_plot <- ~y

plotly::plot_ly(
  data,
  x = x_plot,
  y = y_plot
)

x_dplyr <- formula_to_sym(x_plot)
y_dplyr <- formula_to_sym(y_plot)

select(data, {{ x_dplyr }}, {{ y_dplyr }})

ZacharyWaller/plotlyhelp documentation built on Dec. 18, 2021, 8:26 p.m.