Learn R Programming

butterfly (version 1.1.2)

release: Release: return current dataframe without changed old rows

Description

This function matches two dataframe objects by their unique identifier (usually "time" or "datetime in a timeseries), and returns a new dataframe which contains the new rows (if present) but matched rows which contain changes from previous data will be dropped.

Usage

release(df_current, df_previous, datetime_variable, include_new = TRUE, ...)

Value

A dataframe which contains only rows of df_current that have not changed from df_previous, and includes new rows. Also returns a waldo object as in loupe().

Arguments

df_current

data.frame, the newest/current version of dataset x.

df_previous

data.frame, the old version of dataset, for example x - t1.

datetime_variable

string, which variable to use as unique ID to join df_current and df_previous. Usually a "datetime" variable.

include_new

boolean, should new rows be included? Default is TRUE.

...

Other waldo::compare() arguments can be supplied here, such as tolerance or max_diffs. See ?waldo::compare() for a full list.

See Also

loupe()

create_object_list()

Examples

Run this code
# Dropping matched rows which contain changes, and returning unchanged rows
df_released <- butterfly::release(
  butterflycount$march, # New or current dataset
  butterflycount$february, # Previous version you are comparing it to
  datetime_variable = "time", # Unique ID variable they have in common
  include_new = TRUE # Whether to include new rows or not, default is TRUE
)

df_released

Run the code above in your browser using DataLab