compare: Compare Objects

View source: R/compare.R

compareR Documentation

Compare Objects

Description

Compare two objects as sets.

Usage

compare(A, B, ...)

## S3 method for class 'data.frame'
compare(A, B, zoom = TRUE, ...)

## Default S3 method:
compare(A, B, ...)

## S3 method for class ''function''
compare(A, B, useSource = TRUE, external = FALSE,
  viewer = if (.Platform$OS.type == "windows") "winmerge" else "kompare",
  ...)

Arguments

A

object to compare.

B

object to compare.

...

passed to compare.* methods.

zoom

whether to show only data frame columns whose values differ.

useSource

whether source code format and comments matter, otherwise R standard format is used.

external

whether to compare using an external viewer.

viewer

an external program to use if external=TRUE.

Value

List with 4 elements:

both

items found in both objects

A

items found only in A

B

items found only in B

same.data

whether objects contain the same set of items

Note

Set comparison ignores duplicates and order: c(1,1,2,3) and c(3,2,1) are similar. Similarly, when comparing two functions, the following are the same set:

f <- function(x)    g <- function(x)
{                   {
  y <- 1              y <- 3
  y <- 1              y <- 2
  y <- 2              y <- 1
  y <- 3            }
}

Data frames are compared line by line, and must have the same dimensions.


arnima-github/arni documentation built on Oct. 28, 2023, 6:18 p.m.