R/rearrange_df_columns.R

Defines functions rearrange_df_columns

rearrange_df_columns <- function(df, cols_to_move, col_anchor) {
  
  col_anchor_n <- which(names(df) == col_anchor)
  
  df <- df %>%
    dplyr::select( tidyr::all_of(names(df)[1:col_anchor_n]), tidyr::all_of(cols_to_move), dplyr::everything() )
  
  df
}

Try the FAST.R package in your browser

Any scripts or data that you put into this service are public.

FAST.R documentation built on June 22, 2024, 6:48 p.m.