base::attr with a default value instead of NULL, and always exact

attr(x, which, default_value = "", exact = TRUE)

Arguments

x

an object whose attributes are to be accessed.

which

a non-empty character string specifying which attribute is to be accessed.

default_value

value to return when object x has no attribute which

exact

logical: should which be matched exactly?