tidymodels / infer

An R package for tidyverse-friendly statistical inference
https://infer.tidymodels.org
Other
725 stars 80 forks source link

Use tidyeval functionality #17

Closed mine-cetinkaya-rundel closed 7 years ago

mine-cetinkaya-rundel commented 7 years ago

This is relevant to calculate but maybe others too, if any of those use underscore verbs from dplyr, which is now deprecated functionality.

Prototype for calculating for stat == "mean"

  if (stat == "mean") {
    col <- setdiff(names(x), "replicate")
    x %>%
      dplyr::group_by(replicate) %>%
      dplyr::summarize(stat = mean(!!sym(col)))
  }

Note that this requires importing the sym function from the rlang package, which dplyr currently does not import automatically.

Is someone up for updating the calculate function with this, or should I? We also need to resolve #15 and #16 to and all of the updates can be done at once.

andrewpbray commented 7 years ago

I'll do this. Will give me a chance to play around with this new formulation.

ismayc commented 7 years ago

Is there a way to have the stat in dplyr::summarize(stat = mean(!!sym(col))) be variable based on the statistic chosen using the tidyeval/rlang syntax? Having the column be named stat does work but I wonder about students being confused/forgetting, what the statistic was that they calculated.

rpruim commented 7 years ago

Follow with %>% rename()?

ismayc commented 7 years ago

@andrewpbray Can this be closed?

github-actions[bot] commented 3 years ago

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.