Skip to contents

This function calculates the percent change between corresponding columns in two dataframes and inserts these changes as new columns in the second dataframe. It assumes that the first column in each dataframe is an unused ID column.

Usage

calculate_and_insert_percent_change(data1, data2, col_name)

Arguments

data1

The original dataframe.

data2

The second dataframe to which the percent change columns will be added.

col_name

The name of the column (as a character string) to calculate the percent change for.

Value

A dataframe with the new percent change columns added to data2.

Note

Both data1 and data2 must have the same structure and number of rows. Column 1 should be excluded from calculations.