# Weighted kernel density plot in R

I've subsetted and plotted my unweighted data, but I don't see how to make use of my weighting variable "FactBx$expwgt" ##################################################### plot( density(FactB1$BAV_DIST),
#### xlim=range( c(FactB1$BAV_DIST, FactB2$BAV_DIST, FactB3$BAV_DIST) ), xlim = c(0, 10), main = "Density Plots", xlab = "miles", col = 2 ) lines(density(FactB2$BAV_DIST), col=3)
lines(density(FactB3$BAV_DIST), col=4) lines(density(FactB6$BAV_DIST), col=5)

TextVect <- c("Walk","Bicycle","Auto{Dropped}","Auto{Parked}")
ColorVect <- c(2,3,4,5)
LineVect <- c(0,1,2,3)

mtext(TextVect, side = 1, line = LineVect, col = ColorVect)
###########################################################


I've been using the survey package to do weighted summaries, but I don't see how to do weighted density plots.

-
The density function has a "weights = " parameter; would this be what you want? –  jbowman Feb 3 '12 at 23:07