Skip to contents

This function renames columns in a data frame based on specified old names and corresponding new names.

Usage

renameColumns(
  df,
  old_names = c("Estimate", "Std..Error", "z.value", "Pr...z.."),
  new_names = c("estimate", "std.error", "statistic", "p.value")
)

Arguments

df

A data frame.

old_names

A character vector containing the old column names to be replaced.

new_names

A character vector containing the corresponding new column names.

Value

The data frame with renamed columns.

Examples

df <- data.frame(Estimate = c(1.5, 2.0, 3.2),
                 Std..Error = c(0.1, 0.3, 0.2),
                 z.value = c(3.75, 6.67, 4.90),
                 Pr...z.. = c(0.001, 0.0001, 0.002))

renamed_df <- renameColumns(df, old_names = c("Estimate", "Std..Error", "z.value", "Pr...z.."),
                              new_names = c("estimate", "std.error", "statistic", "p.value"))