get_same_class: Harmonizes variable classes between two data frames

View source: R/reconcile.R

get_same_classR Documentation

Harmonizes variable classes between two data frames

Description

This function aligns the classes of variables in 'old_df' with those of their corresponding variables in 'new_df'. For each column name shared across both data frames, the function detects the class in 'new_df' and coerces the matching column in 'old_df' to the same class. Supported conversions include 'character', 'numeric', 'integer', 'logical', 'factor', and 'Date'. Any variable whose class is not explicitly handled is left unchanged.

Usage

get_same_class(old_df, new_df)

Arguments

old_df

A data frame containing the preceding version of the data, used as the reference for comparison.

new_df

A data frame containing the most recent version of the data.

Value

A modified version of 'old_df' in which all shared columns are coerced to match the variable classes of 'new_df'.

Author(s)

Lukasz Andrzejewski


datetoiso documentation built on Dec. 7, 2025, 9:06 a.m.