Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

has_slot

Does the S4 input have a slot?


Description

Checks to see if the object is an S4 object with a particular slot.

Usage

assert_has_slot(x, severity = getOption("assertive.severity", "stop"))

has_slot(x, slotname, .xname = get_name_in_parent(x))

Arguments

x

Input to check. Intended to be an S4 object.

severity

How severe should the consequences of the assertion be? Either "stop", "warning", "message", or "none".

slotname

A string naming a slot to check for.

.xname

Not intended to be used directly.

Value

has_names returns TRUE if names is non-null.

See Also

Examples

setClass("numbers", representation(foo = "numeric"))
x <- new("numbers", foo = 1:10)
has_slot(x, "foo")
has_slot(x, "bar")
has_slot(1:10, "foo")

assertive.properties

Assertions to Check Properties of Variables

v0.0-4
GPL (>= 3)
Authors
Richard Cotton [aut, cre]
Initial release
2016-12-29

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.