Description Usage Arguments Value Author(s) References See Also Examples
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.
1 | addBoundary(pop, sea = 2, land.mean = mean(unlist(pop)))
|
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. |
land.mean |
the scalar value that we use as the value for the cells we with which we surround the existing matrix. This is the value for all the cells in the sea region. |
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
1 2 3 4 5 6 7 8 9 | m = matrix(1, 5, 7)
mm = col(m)
ex = addBoundary(mm)
dim(ex)
image(ex)
ex = addBoundary(mm, 1)
dim(ex)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.