[R] Kind of 2 dim histogram - levelplot

Deepayan Sarkar deepayan.sarkar at gmail.com
Wed Jul 6 00:05:18 CEST 2005

On 7/5/05, Hans-Peter <gchappi at gmail.com> wrote:
> Dear R-List,
> I've written some code to put measurement values at a position x and y
> in bins (xb and yb). It works, but I wonder if there isn't a function
> that would do what I do by hand in "# fill data in bins"?

Here's one way:

tab = table(cut(x, breaks = 1:4), cut(y, breaks = 4:7))
levelplot(tab, xlim = rownames(tab), ylim = colnames(tab))

You might also want to try the hexbin package, which does hexagonal
binning as opposed to rectangular binning here.


More information about the R-help mailing list