Blog Archives

Converting values to color levels

September 12, 2011
By
Converting values to color levels

     Adding color to a plot is helpful in many situations for visualizing an additional dimension of the data. Again, I wrote the below function "val2col" in R after having coded this manually over and over in the past. It uses similar arguments as the image function in that one defines the...

Read more »

Adding a scale to an image plot

August 31, 2011
By
Adding a scale to an image plot

Here's a function that allows you to add a color scale legend to an image plot (or probably any plot needing a z-level scale). I found myself having to program this over and over again, and just decided to make a plotting function for future use. While I really like the look of levelplot(),...

Read more »

Creating svg graphics for web publishing

July 25, 2011
By

<p><p><p><p><p><p><p><p>This is an error message. If you are reading this, something broke. You may need to upgrade your browser. </p></p></p></p></p></p></p></p> Thanks to the nice post from Revolution Analytics I was finally able to get an svg device working on my Windows OS version of R. It took some additional tips from a fellow user of blogger to...

Read more »

Color reduction of an image – and Warholize?

July 5, 2011
By
Color reduction of an image – and Warholize?

There seems to be several methods out there for reducing the colors in an image. I became interested in this after pondering how this is done in the excellent freeware program IrfanView. Unfortunately, their method is not described anywhere that I coul...

Read more »

Clarke and Ainsworth’s BIOENV and BVSTEP (and BIO-BIO etc…)

June 30, 2011
By
Clarke and Ainsworth’s BIOENV and BVSTEP (and BIO-BIO etc…)

Nonmetric Multidimensional Scaling (NMDS) plot of vegetation sample dissimilarities with best correlating environmental variables (left) and species (right) plotted as vectors (datasets "varespec" and "varechem" from the package ...

Read more »

Image color palette replacement

June 9, 2011
By
Image color palette replacement

Here is an example of a function I wrote to change the color palette used in an image. The above example comes from a black and white original, although color images can also be used. The function first converts the image to grayscale in order to have ...

Read more »

Simulating CMYK mis-registration printing

June 3, 2011
By
Simulating CMYK mis-registration printing

I recently came across a poster advertising a children's production of Shakespeare's The Tempest where they purposely used an effect to mimic a mis-registration in CMYK printing. You have probably seen this before as a slight offset in one of t...

Read more »

map.xyz(): interpolation of XYZ data and projection onto a map

May 30, 2011
By
map.xyz(): interpolation of XYZ data and projection onto a map

     I am still struggling to get a grasp of R's mapping capabilities. Part of my frustration lies in the fact that I often work on areas near the poles, which complicates interpolation across the 180 degree line. For smaller areas, interpolati...

Read more »

Array position to matrix coordinates conversion

May 30, 2011
By
Array position to matrix coordinates conversion

#A function that is sometimes useful in determining the #coordinate(i.e. row and column number) of a matrix position#(and vice-versa). #Either a vector of positions ("pos") #OR a 2 column matrix of matrix coordinates, ("coord", i.e. cbind(row,col)), #A...

Read more »

R functions for Earth geographic coordinate calculations

May 29, 2011
By
R functions for Earth geographic coordinate calculations

Here are some functions that I regularly use for geographic data (e.g. binning, filtering, calculation of new positions etc.).#distance in kilometers between two long/lat positions (from "fossil" package)earth.dist <- function (long1, lat1, long2, l...

Read more »