Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trace_position tidy evaluation #60

Closed
sheridar opened this issue Nov 20, 2023 · 1 comment
Closed

trace_position tidy evaluation #60

sheridar opened this issue Nov 20, 2023 · 1 comment

Comments

@sheridar
Copy link
Member

Currently an expression passed to trace_position is captured with substitute() and evaluated strictly within the context of the data. This means the user cannot use environment variables with trace_position. Ideally the user would be able to include both environment and data variables such as in the example below, which does not work with ggtrace v0.2.0.

To accomplish this, need to include a data mask (with rlang::eval_tidy()) when evaluating trace_position

create_trace_plot <- function(data, traceVar = "xVar", traceThreshold = -1) {

  pl <- ggplot(data = data, aes(xVar, yVar, fill = fill_var), color = "#000000") +
    geom_point_trace(
      trace_position = !!sym(traceVar) < traceThreshold,

      fill = "#FFFFFF",
      background_params = list(color = "#000000", fill = "#CC0000")
    ) +
    ggtitle(str_c("Threshold: ", traceThreshold))

  pl
}
@sheridar
Copy link
Member Author

Closed with #59

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant