compare.matrix {SDMTools}R Documentation

Biplot Comparison of Matrices


compare.matrix compares the values within two matrices (e.g., ESRI ArcInfo ASCII raster files) and produces a biplot that shows the frequency of each data combination shared between the matrices. The plot is overlayed with contour lines that demarcate parts of the the plot that share the same frequency of data combinations.

NOTE: it is assumed the matrices are of the same extent, cell size and scaled to be the same units.


compare.matrix(x, y, nbins, ...)



a matrix of data; the matrix can be a raster of class 'asc' (adehabitat package), 'RasterLayer' (raster package) or 'SpatialGridDataFrame' (sp package)


a matrix of data of the same extent, cell size and class as 'x'


number of equally spaced bins used to partition range of values in 'x' & 'y'


other graphical parameters defined by image(), contour(), or plot()


Nothing is returned but images are created.


Luke Shoo


#create some simple objects of class 'asc'
tasc = as.asc(matrix(rep(x=1:10, times=1000),nr=100)); print(tasc)
#modify the asc objects so that they are slightly different
tasc1 = tasc + runif(n = 10000, min = -1, max = 1)
tasc2 = tasc + rnorm(n = 10000, mean = 1, sd = 1)

#create some images
#basic plot showing the density of data combinations shared
#by the two matrices

#same as previous but with data partioned amoung more bins

#same as previous but altering the number of contour levels
#and adding more graphical functions
compare.matrix(tasc1,tasc2,50,nlevels=5, xlab='asc1',ylab='asc2',
  main='Comparison between asc and asc2', bg="grey")

[Package SDMTools version 1.1-221 Index]