Retrieves or assigns a unit attribute to an R object.
Value
unit(x)returns the unit as a character string orNULL.unit(x) <- valuereturnsxwith updated unit attribute.
Details
The unit is stored as a simple character string in the "unit" attribute.
This provides a lightweight mechanism for attaching unit metadata to objects,
without enforcing any automatic conversion or validation.
The setter does not validate whether the unit is physically meaningful.
Validation and conversion should be handled externally (e.g., via
a unit conversion engine such as ConvUnit7).
Assigning NULL removes the unit attribute.
See also
Other format:
convUnit(),
fm(),
fmCI(),
print.Unit(),
style()
