[R] Constrain density to 0 at 0?
David Winsemius
dwinsemius at comcast.net
Tue Jul 20 04:30:46 CEST 2010
On Jul 19, 2010, at 9:57 PM, Farley, Robert wrote:
> I'm plotting some trip length frequencies using the following code:
>
> plot( density(zTestData$Distance, weights=zTestData$Actual),
> xlim=c(0,10),
> main="Test TLFD",
> xlab="Distance",
> col=6 )
> lines(density(zTestData$Distance, weights=zTestData$FlatWeight),
> col=2)
> lines(density(zTestData$Distance, weights=zTestData$BrdWeight ),
> col=3)
>
> which works fine except the distances are all positive, but the
> densities don't drop to 0 until around -2 or -3.
>
> Is there a way for me to "force" the density plot to 0 at 0?
Yes. (Assuming it can be zero, given the data.)
Read the help page for density more carefully. Especially the bw and
from arguments.
--
David.
More information about the R-help
mailing list