setattr: Set attributes of objects by reference

Description Usage Arguments Details References See Also

View source: R/utilities.R

Description

setattr changes the attribute of an object by reference, that is, without making any copy. This is an imported and re-exported function from the data.table package with two minor enhancements (see Details).

Usage

1
setattr(x, name, value, check_for = NULL)

Arguments

x

an object

name

the name of the attribute (a character string)

value

the value to assign to the attribute. If value is NULL, setattr removes the attribute (if present).

check_for

an object which might have the same address in RAM as 'x' but should not be affected by setattr

Details

The original setattr function has an undesirable consequence on !FALSE or !TRUE if the 'x' object is a logical scalar (see References). This function corrects this bug. Additionally, the standard attr function is applied for such an 'x' object, which is referenced to the 'check_for' object (has the same address in RAM, see address).

References

https://github.com/Rdatatable/data.table/issues/1281

See Also

setattr for the original version in the data.table package


tdeenes/eegR documentation built on April 19, 2021, 4:17 p.m.