Description Usage Arguments Details Value Note See Also Examples
Divide the range of x and y into intervals, thus forming a matrix of bins, and apply an arbitrary function to the z values corresponding to each bin.
| 1 2 3 4 5 | 
| x, y, z | Numeric vectors, or possibly a matrix. | 
| FUN | Function to summarize z values. | 
| nx, ny | Approximate number of bins along x and y axis. | 
| xlim, ylim | Limit the range of data points considered. | 
| xbreaks, ybreaks | Breakpoints between bins along x and y axes. | 
| right | Logical; if TRUE, the intervals will be closed on the right (and open on the left). | 
| include.lowest |  Logical, indicating if an  | 
| ... |  Further arguments to  | 
x, y and z values can be passed to squash in any form recognized by xyz.coords (e.g. individual vectors, list, data frame, formula).
Alternatively, data that is already in a matrix can be passed in any format recognized by xyzmat.coords.
FUN should accept a numeric vector and return a single numeric value (e.g. mean, median, min, max, sd).
If xbreaks is not specified, approximately nx breakpoints will be generated automatically to span the data; likewise for ybreaks and ny.
The output can be visualized with colorgram, image, etc.
A list with components
| x  | Vector of breakpoints along the x-axis. | 
| y  | Vector of breakpoints along the y-axis. | 
| z  | Matrix of values representing the summary for each bin. | 
| xlab  | A label for the x-axis. | 
| ylab  | A label for the y-axis. | 
| zlab  | A label for the z-axis. | 
The defaults of right and include.lowest are opposite the defaults used in cut.
This function is essentially a souped-up version of tapply.
squashgram has similar functionality but with graphical output.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 |   ## earthquake depths as a function of longitude, latitude
  attach(quakes)
  quakedepth <- matapply(depth ~ long + lat, FUN = mean)
  colorgram(quakedepth)
  ## iris petal length vs. sepal length and width
  ipl <- matapply(iris[,1:3], FUN = median, nx = 20, ny = 15 )
  colorgram(ipl, main = 'iris')
    
  ## Example of matrix input; here used to downsample an image 
  colorgram(volcano, colFn = terrain.colors)
  volcano2 <- matapply(volcano, FUN = mean, nx = 20)
  colorgram(volcano2, colFn = terrain.colors)
  
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.