compare_dfs: Compare Data-Frames

Description Usage Arguments Value Examples

View source: R/Compare_DF.R

Description

Compare two data-frame (like) objects. The function will compare the objects by column names, and print information about differences.

Usage

1
2
3
4
5
6
7
8
compare_dfs(
  df1,
  df2,
  printColDiffs = 1,
  tol = 1e-10,
  trim = TRUE,
  blankEqualsNA = FALSE
)

Arguments

df1

The first object inheriting from a data.frame.

df2

The second object inheriting from a data.frame.

printColDiffs

What level of messages to print regarding the differences between columns (integer scalar).

tol

The acceptable tolerance for equality between numeric columns (numeric scalar).

trim

Whether or not to trim whitespace from character columns (logical scalar).

blankEqualsNA

Whether or not blanks and considered equal to NA in character vectors (logical scalar).

Value

A list of column comparison data for each non-identical column.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Returns an empty list, since the objects are identical
compare_dfs(mtcars, mtcars)

# Prints a message about the difference in column names
compare_dfs(mtcars, mtcars[, -1])

# Prints a message about the difference in values, & returns a tibble showing the differences
compare_dfs(mtcars, dplyr::mutate(mtcars, mpg = mpg * 2))

# Same as the above, but doesn't print the message about the differences
compare_dfs(mtcars, dplyr::mutate(mtcars, mpg = mpg * 2), printColDiffs = FALSE)

KO112/KO documentation built on Oct. 2, 2020, 9:21 a.m.