R layout


layout() function divides the device up into as many rows and columns as there are in matrix mat, with the column-widths and the row-heights specified in the respective arguments..

layout(mat, widths = rep.int(1, ncol(mat)),
heights = rep.int(1, nrow(mat)), respect = FALSE)
layout.show(n = 1)
lcm(x)

mat: a matrix object specifying the location of the next N figures on the output device. Each value in the matrix must be 0 or a positive integer. If N is the largest positive integer in the matrix, then the integers {1, …, N-1} must also appear at least once in the matrix.
widths: a vector of values for the widths of columns on the device. Relative widths are specified with numeric values. Absolute widths (in centimetres) are specified with the lcm() function (see examples).
heights: a vector of values for the heights of rows on the device. Relative and absolute heights can be specified, see widths above.
respect: either a logical value or a matrix object. If the latter, then it must have the same dimensions as mat and each value in the matrix must be either 0 or 1.
n: number of figures to plot.
x: a dimension to be interpreted as a number of centimetres.

Let's divide the device into two rows and two columns, allocate figure 1 all of row 1, allocate figure 2 the intersection of column 2 and row 2

> layout(matrix(c(1,1,0,2), 2, 2, byrow = TRUE))
> layout.show(2)


> nf <- layout(matrix(c(2,0,1,3),2,2,byrow = TRUE), c(3,1), c(1,3), TRUE)
> layout.show(nf)







endmemo.com © 2025  | Terms of Use | Privacy | Home