identicalSlots: Judge if the slots in two S4 objects are identical

View source: R/identicalSlots.R

identicalSlotsR Documentation

Judge if the slots in two S4 objects are identical

Description

Judge if the slots in two S4 objects are identical

Usage

identicalSlots(obj1, obj2, slots = NULL, isList = FALSE)

Arguments

obj1

First S4 object

obj2

Second S4 object

slots

The slot names, the default is NULL, which means all of the slot names in the first object.

isList

logical, is the obj1 or obj2 a list, the default is FALSE.

Value

A list of two elements (FALSE and TRUE) if both exists. The slot names in the FALSE element are not identical between two objects. In contrast, the slot names in the TRUE element are identical between two objects.

Examples

## Not run: 
library(Matrix)
i = c(1,3:8)
j = c(2,9,6:10)
x = 7 * (1:7)
(A = sparseMatrix(i, j, x = x))
identicalSlots(A, A)

y = x + 1
(B = sparseMatrix(i, j, x = y))
identicalSlots(A, B)

x = list(a = 1:3, b = letters)
y = list(a = 1:3, b = LETTERS)
identicalSlots(x, y, isList = T)

x = list(a = 1:3, b = letters, c = TRUE)
y = list(a = 1:3, b = LETTERS, c = TRUE)
identicalSlots(x, y, isList = T)

## End(Not run)

paodan/funcTools documentation built on April 1, 2024, 12:01 a.m.