Re: [R] Histogram

From: David Barron <mothsailor_at_googlemail.com>
Date: Tue, 19 Jun 2007 17:23:03 +0100

I expect there's a more elegant way of doing this, but this should work:

set.seed(101)
x <- rnorm(500,sd=.03)
hist (x, seq(-0.1,0.1,0.01),freq = FALSE) d <- density(x,bw="SJ")
lowt <- d$x < -.05
upt <- d$x > .05
lines (d$x[lowt],d$y[lowt], col = "red") lines(d$x[upt],d$y[upt], col = "red")

On 19/06/07, livia <yn19832_at_msn.com> wrote:
>
> Hello, I am using the following codes to plot a histogram and density line
> for x. For the density line, I just want it to show the two tails, eg, for x
> larger than 0.05 ans smaller than -0.05
>
> hist (x, seq(-0.1,0.1,0.01),freq = FALSE)
> lines (density(x,bw="SJ"), x> 0.05 & x< (-0.05), col = "red")
>
> But is does not work, can anyone give me some advice?
>
>
>
> --
> View this message in context: http://www.nabble.com/Histogram-tf3947281.html#a11197644
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help_at_stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
=================================
David Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP

______________________________________________
R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Tue 19 Jun 2007 - 16:41:52 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 19 Jun 2007 - 17:32:09 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.