How to “increase” array resolution in R (replicate each element both column-wise and row-wise)

This post was originally published here

One picture says more than a thousand words. You have what is one the left, and you want what is on the right.

resolution_cut

There are a few different ways to do this, but by far the cleanest and quickest way is to just select the rows and columns multiple times, by replicating row and column numbers (instead of actually replicating each element):

Note that by default, in rep(something, n) the n is times so equivalent to rep(something, times=n), but in this case we need to use each instead of times.

Leave a Reply

Your email address will not be published. Required fields are marked *