Estimate point densities on a regular grid for.

## Usage

`density2d(x, y, facet = NULL, n = 100, margin = "n")`

## Arguments

- x
x coordinates

- y
y coordinates

- facet
factor: estimate for each unique factor; can be NULL

- n
size of the grid

- margin
one of 'n','x' or 'y'; should the density be computed along both axes ('n'), or along 'x' or 'y' axis only

## Value

a density value for each point