| addBoundary {Rcartogram} | R Documentation |
This function is useful for taking the grid of
densities/counts as a matrix and embedding
it in a larger matrix whose additional values
are just the mean of our original matrix.
This new matrix can then be handed to
cartogram to fit the
diffusion cartogram. The extra "padding" or "sea"
helps the algorithm converge.
addBoundary(pop, sea = 0.2)
pop |
the matrix of densities/counts to be embedded. |
sea |
a number which is applied to the dimensions of the original matrix to determine how many rows and columns should be added to the original matrix. Twice as many rows and columns are added as this product, an equal number of rows above and below, and an equal number of columns to the left and to the right. |
A matrix with dimension
floor((1 + 2 * seq) * dim(pop))
and whose "outer" values in the added rows is the mean of
the original matrix pop.
Duncan Temple Lang created the interface for R
"Diffusion-based method for producing density equalizing maps", Michael T. Gastner and M. E. J. Newman, Proc. Natl. Acad. Sci. USA 101, 7499-7504 (2004) http://www.pnas.org/cgi/content/abstract/101/20/7499
m = matrix(1, 5, 7) mm = col(m) ex = addBoundary(mm) dim(ex) image(ex) ex = addBoundary(mm, 1) dim(ex)