Home > OS >  R dyplyr alternative for accross function
R dyplyr alternative for accross function

Time:07-13

I have a peice of code that I want to rewrite for an older version of dplyr, where there is no function accross. Here is the code I have right now:

grouping_columns <- as_name(plot_columns[["xaxis"]])
grouping_columns <- append(grouping_columns, as_name(plot_columns[["color"]]))
data <- plot_data %>%
  group_by(across(all_of(grouping_columns))) %>%
  summarise(n = n(), offset = min(result_value),
            reorder_result_value = mean(result_value)) %>%
  as.data.frame

I am relatively new to R and days of google didnt help much... I need the same result, but without across. The server I am deploying the shiny app has dplyr 0.8.5, and across came around 0.9.

CodePudding user response:

Use group_by_at() instead:

  group_by_at(grouping_columns) %>%
  • Related