unit package:grid R Documentation _F_u_n_c_t_i_o_n _t_o _C_r_e_a_t_e _a _U_n_i_t _O_b_j_e_c_t _D_e_s_c_r_i_p_t_i_o_n: This function creates a unit object - a vector of unit values. A unit value is typically just a single numeric value with an associated unit. _U_s_a_g_e: unit(x, units, data=NULL) _A_r_g_u_m_e_n_t_s: x: A numeric vector. units: A character vector specifying the units for the corresponding numeric values. data: This argument is used to supply extra information for special 'unit' types. _D_e_t_a_i_l_s: 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: '"_n_p_c"' Normalised Parent Coordinates (the default). The origin of the viewport is (0, 0) and the viewport has a width and height of 1 unit. For example, (0.5, 0.5) is the centre of the viewport. '"_c_m"' Centimetres. '"_i_n_c_h_e_s"' Inches. 1 in = 2.54 cm. '"_m_m"' Millimetres. 10 mm = 1 cm. '"_p_o_i_n_t_s"' Points. 72.27 pt = 1 in. '"_p_i_c_a_s"' Picas. 1 pc = 12 pt. '"_b_i_g_p_t_s"' Big Points. 72 bp = 1 in. '"_d_i_d_a"' Dida. 1157 dd = 1238 pt. '"_c_i_c_e_r_o"' Cicero. 1 cc = 12 dd. '"_s_c_a_l_e_d_p_t_s"' Scaled Points. 65536 sp = 1 pt. '"_l_i_n_e_s"' Lines of text. Locations and dimensions are in terms of multiples of the default text size of the viewport (as specified by the viewport's 'fontsize' and 'lineheight'). '"_c_h_a_r"' Multiples of nominal font height of the viewport (as specified by the viewport's 'fontsize'). '"_n_a_t_i_v_e"' Locations and dimensions are relative to the viewport's 'xscale' and 'yscale'. '"_s_n_p_c"' Square Normalised Parent Coordinates. Same as Normalised Parent Coordinates, except gives the same answer for horizontal and vertical locations/dimensions. It uses the _lesser_ of npc-width and npc-height. This is useful for making things which are a proportion of the viewport, but have to be square (or have a fixed aspect ratio). '"_s_t_r_w_i_d_t_h"' Multiples of the width of the string specified in the 'data' argument. The font size is determined by the pointsize of the viewport. '"_s_t_r_h_e_i_g_h_t"' Multiples of the height of the string specified in the 'data' argument. The font size is determined by the pointsize of the viewport. '"_g_r_o_b_w_i_d_t_h"' Multiples of the width of the grob specified in the 'data' argument. '"_g_r_o_b_h_e_i_g_h_t"' Multiples of the height of the grob specified in the 'data' argument. 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 (e.g., 'unit(1:5, "npc")[2:4]'), 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"))'). _V_a_l_u_e: An object of class '"unit"'. _W_A_R_N_I_N_G: There is a special function 'unit.c' for concatenating several unit objects. The 'c' function will not give the right answer. There used to be '"mylines"', '"mychar"', '"mystrwidth"', '"mystrheight"' units. These will still be accepted, but work exactly the same as '"lines"', '"char"', '"strwidth"', '"strheight"'. _A_u_t_h_o_r(_s): Paul Murrell _S_e_e _A_l_s_o: 'unit.c' _E_x_a_m_p_l_e_s: unit(1, "npc") unit(1:3/4, "npc") unit(1:3/4, "npc") + unit(1, "inches") min(unit(0.5, "npc"), unit(1, "inches")) unit.c(unit(0.5, "npc"), unit(2, "inches") + unit(1:3/4, "npc"), unit(1, "strwidth", "hi there"))