kernel_density_2d: 2d dernel density estimate.

Description Usage Arguments Details Examples

Description

2d dernel density estimate.

Usage

1
2
kernel_density_2d(x, y, weight, xbandwidth="bw.nrd",
    ybandwidth="bw.nrd", na.rm=FALSE)

Arguments

x

a numeric vector of x positions

y

a numeric vector of y positions

weight

NULL or a numeric vector providing weights for each observation

xbandwidth

bandwith for x direction. Either a number or a function to calculate the binwidth from the data.

ybandwidth

bandwith for y direction. Either a number or a function to calculate the binwidth from the data.

na.rm

If TRUE missing values will be silently removed, otherwise they will be removed with a warning.

Details

Only normal kernel/weight function currently implemented. This function is based on kde2d but extended to allow weights, and to compute density at arbitrary position.

Examples

1
2
3
data(baseball, package = "plyr")
dens <- kernel_density_2d(baseball$g, baseball$ab)
plot(dens)

hadley/densityvis documentation built on May 17, 2019, 9:56 a.m.