[R] How to shade part of a density plot

Stuart Luppescu s-luppescu at uchicago.edu
Sun May 19 20:31:30 CEST 2002

I'm trying to shade part of a density plot. The code I'm trying (using
the Old Faithful data as an example) is something like this:

# The Old Faithful geyser data
d <- density(faithful$eruptions, bw = "sj")
polygon(d[d$x>4], col = "wheat")

I expected that the part of the curve to the right of 4 on the x axis
should be shaded, but nothing gets shaded at all. In fact, when I just
try to print d[d$x>4] I get many lines of 
I must be mistaken in my understanding of density objects. Could someone
clear up my mistake? Thanks very much.
Stuart Luppescu       -=- s-luppescu at uchicago.edu
University of Chicago -=- CCSR 
才文と智奈美の父    -=- Kernel 2.4.18-xfs              
checkuary, n:  The thirteenth month of the year.  Begins New
 Year's Day and ends  when a person stops absentmindedly
 writing the old year on his checks. 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 240 bytes
Desc: This is a digitally signed message part
Url : https://stat.ethz.ch/pipermail/r-help/attachments/20020519/f5e01aa2/attachment.bin

More information about the R-help mailing list