carol white <wht_...@yahoo.com> wrote
>Consider a vector of 100 elements (attached files). then, 
>
>truehist(b)
>lines(density(b[20:50]))
>
>How is it possible to have density plots of all subsets like b[20:50] within 
>histogram (without exceeding the max of historgram on y axis)?
>


I didn't open your attached file  but 

b <- rnorm(100)
library(MASS)
truehist(b)
lines(density(b[20:50]))


works fine

if some of your density plots line go too high, then you can first find the 
maximum and then use that in the truehist function, which has ymax.

There's probably some elegant way to find the max, but I *THINK* this is right:
den1 <- density(b[20:50])
max1 <- max(den1[[2]])

then, if you have a lot of densities, you could get
maxim <- max(max1, max2) or some such

HTH

Peter


Peter L. Flom, PhD
Statistical Consultant
www DOT peterflomconsulting DOT com

______________________________________________
R-help@r-project.org 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.

Reply via email to