The package 'pendensity' offers routines for estimating penalized unconditional and conditional (on factor groups) densities.
Useful links