Unit objects allow the user to specify locations and dimensions
in a large number of different coordinate systems. All drawing
occurs relative to a viewport and the units
specifies
what coordinate system to use within that viewport. Possible units
(coordinate systems) are:
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
A number of variations are also allowed for the most common units.
For example, it is possible to use "in"
or "inch"
instead of "inches"
and "centimetre"
or
"centimeter"
instead of "cm"
.
A special units
value of "null"
is also allowed,
but only makes sense when used in specifying widths of columns
or heights of rows in grid layouts (see grid.layout
).
The data
argument must be a list when the unit.length()
is greater than 1. For example,
unit(rep(1, 3), c("npc", "strwidth", "inches"),
data = list(NULL, "my string", NULL)).
It is possible to subset unit objects in the normal way and to perform
subassignment (see the examples),
but a special function
unit.c
is provided for combining unit objects.
Certain arithmetic and summary operations are defined for
unit objects. In particular, it is possible to add and subtract
unit objects (e.g., unit(1, "npc") - unit(1, "inches")
),
and to specify the minimum or maximum of a list
of unit objects (e.g., min(unit(0.5, "npc"), unit(1,
"inches"))
).