getChangesOfDuplicates: Get Changes of Rows That Are Duplicated in Selected Columns

View source: R/utils_berlin.R

getChangesOfDuplicatesR Documentation

Get Changes of Rows That Are Duplicated in Selected Columns

Description

Get Changes of Rows That Are Duplicated in Selected Columns

Usage

getChangesOfDuplicates(df, columns, add_columns = columns)

Arguments

df

a data frame

columns

names of columns in df in which to look for duplicate value combinations

add_columns

names of additional columns that shall appear in the output even if there are no changes in these columns

Value

list of data frames. The list has as many elements as there are different value combinations in columns that appear more than once in df. Each element is a data frame with all rows from df that have the same value combination in columns. By default the data frame contains the columns given in columns and those columns out of df in which there is at least one change over the values in the different rows.

Examples

df <- data.frame(
  id = 1:7, 
  name = c("one", "one", "two", "two", "three", "three", "three"), 
  type = c("A", "A", "B", "C", "D", "D", "D"),
  size = c(10, 11, 12, 12, 13, 13, 14),
  height = c(1, 1, 2, 3, 4, 4, 5)
)

df

getChangesOfDuplicates(df, "name")
getChangesOfDuplicates(df, c("name", "type"))


KWB-R/kwb.prep documentation built on June 11, 2022, 1:29 p.m.