Last data update: 2014.03.03

R: Biplot Comparison of Matrices
compare.matrixR Documentation

Biplot Comparison of Matrices

Description

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.

Usage

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

Arguments

x

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

y

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

nbins

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

...

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

Value

Nothing is returned but images are created.

Author(s)

Luke Shoo luke.shoo@jcu.edu.au

Examples

#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
compare.matrix(tasc1,tasc2,20)

#same as previous but with data partioned amoung more bins
compare.matrix(tasc1,tasc2,50)

#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")

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(SDMTools)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/SDMTools/compare.matrix.Rd_%03d_medium.png", width=480, height=480)
> ### Name: compare.matrix
> ### Title: Biplot Comparison of Matrices
> ### Aliases: compare.matrix
> 
> ### ** Examples
> 
> #create some simple objects of class 'asc'
> tasc = as.asc(matrix(rep(x=1:10, times=1000),nr=100)); print(tasc)
Raster map of class "asc":
Cell size:  1 
Number of rows:  100 
Number of columns:  100 
Type:  numeric 
> #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
> compare.matrix(tasc1,tasc2,20)
> 
> #same as previous but with data partioned amoung more bins
> compare.matrix(tasc1,tasc2,50)
> 
> #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")
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>