compare_df: Compare two data frames by keys

Description Usage Arguments Value Examples

View source: R/exploratory_data_analysis.R

Description

Obtain differences between two data frames

Usage

1
2
compare_df(dfcomp_x, dfcomp_y, keys_x, keys_y = NA,
  compare_values = FALSE)

Arguments

dfcomp_x

first data frame to compare

dfcomp_y

second data frame to compare

keys_x

keys of the first dataframe

keys_y

(optional) keys of the second dataframe, if missing both data frames will be compared with the keys_x

compare_values

(optional) if TRUE it will not only compare keys, but also will check if the values of non-key matching columns have the same values

Value

Differences and coincident values

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
data(heart_disease)
a=heart_disease
b=heart_disease
a=subset(a, age >45)
b=subset(b, age <50)
b$gender='male'
b$chest_pain=ifelse(b$chest_pain ==3, 4, b$chest_pain)
res=compare_df(a, b, c('age', 'gender'))
# Print the keys that didn't match
res
# Accessing the keys not present in the first data frame
res[[1]]$rows_not_in_X
# Accessing the keys not present in the second data frame
res[[1]]$rows_not_in_Y
# Accessing the keys which coincide completely
res[[1]]$coincident
# Accessing the rows whose values did not coincide
res[[1]]$different_values

funModeling documentation built on Sept. 9, 2019, 1:02 a.m.