rename_columns_using_table of new and old names

first time use of tibble::deframe

Auteur

Simon Coulombe

Date de publication

16 août 2024

create a function from this code found on stackoverflow https://stackoverflow.com/questions/67493635/how-to-rename-columns-in-a-table-by-using-a-table-of-old-and-new-names-in-r-tid

’’’
#’ rename_columns_using_table
#’
#’ @param df
#’ @param rename_table
#’
#’ @return
#’ @export
#’
#’ @examples
#’ rename_columns_using_table(iris, dplyr::tribble(
#’ ~newname, ~oldname,
#’ “sep_length”, “Sepal.Length”,
#’ “set_width”, “Sepal.Width”
#’
#’))
rename_columns_using_table <- function(df, rename_table){
df %>%
rename(!!! tibble::deframe(rename_table))

}

’’’

Réutilisation

Citation

BibTeX
@online{coulombe2024,
  author = {Coulombe, Simon},
  title = {rename\_columns\_using\_table of new and old names},
  date = {2024-08-16},
  url = {https://aidememoire.netlify.app/rstats/rename_columns_using_table.html},
  langid = {fr}
}
Veuillez citer ce travail comme suit :
Coulombe, Simon. 2024. “rename_columns_using_table of new and old names.” August 16, 2024. https://aidememoire.netlify.app/rstats/rename_columns_using_table.html.