[R] truehist and density plots

Uwe Ligges ligges at statistik.tu-dortmund.de
Tue Apr 28 14:42:02 CEST 2009



carol white wrote:
> Hi,
> I wanted to plot the histogram of a vector and then, plot the density function of subsets of the vector on the histogram. So I use truehist in MASS package and lines(density) as follows:
> 
> length(b) = 1000
> truehist(b)
> lines(density(b[1:100]))


I do not undertsand what you mean. Can you please provide a 
*reproducible* example?

Uwe Ligges


> however the density plot of the first 100 points exceeds the max of y axis (see attached). how is it possible to make a graphics so that the density plot of the subsets doesn't go beyond the maximum of all points in the complete set?
> 
> Cheers,
> 
> Carol
> 
> 
> 
> 
> 
> 
>       
> 
> 
> ------------------------------------------------------------------------
> 
> ______________________________________________
> R-help at 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.




More information about the R-help mailing list