liveBook · Manning

Across() function

As explained in Statistics Slam Dunk

The across() function from dplyr applies a transformation or summary expression across selected columns in a data operation.

Use dplyr’s across() inside summarize() to apply the same calculation across selected columns. In salary analysis, it computes mean payrolls for consecutive season columns while na.rm = TRUE ignores missing values. section 10.3

Average NBA payroll by season

salaries %>% summarize(across(s2017:s2000, mean, na.rm = TRUE)) produces one row with 18 seasonal averages. Apply the same pattern to adjusted salary columns with across(sa2017:sa2000, mean, na.rm = TRUE), then use pivot_longer() to prepare the results for plotting. section 10.3

How Statistics Slam Dunk covers it

How deep it goes
Demonstrates syntax, contiguous column selection, missing-value handling, and subsequent reshaping, but does not explain implementation internals.
Examples
Uses real and inflation-adjusted NBA team payroll columns from 2000 through 2017.
What you can do after
Apply it via dplyr to calculate matching summaries across selected columns and reshape the output for comparison charts.
How it connects
Connects across() with summarize(), pivot_longer(), and ggplot2 visualization.

This explainer was generated by Manning's knowledge graph from the text of Statistics Slam Dunk. The section links point to the parts of the book it draws on.