I am trying to rename a few columns using dplyr::rename
and tidyselect helpers to do so using some patterns.
How can I get this to work?
library(tidyverse)
# tidy output from broom (using development version)
(df <- broom::tidy(stats::oneway.test(formula = wt ~ cyl, data = mtcars)))
#> # A tibble: 1 x 5
#> num.df den.df statistic p.value method
#> <dbl> <dbl> <dbl> <dbl> <chr>
#> 1 2 19.0 20.2 0.0000196 One-way analysis of means (not assuming equ~
# renaming
df %>%
dplyr::rename(
.data = .,
parameter1 = dplyr::matches("^num"),
parameter2 = dplyr::matches("^denom")
)
#> Error: Column positions must be scalar
Created on 2020-01-12 by the reprex package (v0.3.0.9001)