harmonize_columns: Harmonize columns in a list of data frames

View source: R/harmonize_columns.R

harmonize_columnsR Documentation

Harmonize columns in a list of data frames

Description

This function takes a list of data frames and adds missing columns to each data frame so that all data frames have the same columns in the same order.

Usage

harmonize_columns(df_list)

Arguments

df_list

A list of data frames

Details

Any added columns will be populated with NAs. The function can be used to prepare data frames for an rbind when the columns are not identical.

Value

A list of data frames with harmonized columns

Examples

# Create some example data frames
df1 <- data.frame(a = 1:3, b = letters[1:3])
df2 <- data.frame(b = letters[4:6], c = 4:6)
df3 <- data.frame(a = 7:9, c = letters[7:9])

# Harmonize columns
harmonize_columns(list(df1, df2, df3))

dryguy/rbitr documentation built on Oct. 15, 2024, 6:18 a.m.