source("http://macosa.dima.unige.it/r.R") # If I have not already loaded the library ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- [ continuation from here, paragraph (N_3) ] To produce histograms of already classified data, which are not easy to trace with standard commands, you can use the histoclas command. An example: in Italy in 1951, in the age intervals [0,5),[5,10),[10,20),[20,30),[30,40),[40,50),[50,60),[60,75),[75,100) are dead 729,35,77,132,134,285,457,1401,1569 thousand people (if the extremes of the intervals are N the frequencies are N-1) # interv = c(0, 5, 10, 20, 30, 40, 50, 60, 75, 100) freq = c(729,35,77, 132,134,285,457,1401,1569) histoclas(interv,freq) # The mean (brown dot) is about 58.31897 # For percentages use PERC For other statistics use the morestat() # If I write noMean=1; histoclas(interv,freq) the mean is not shown. PERC # 15.13 0.73 1.60 2.74 2.78 5.91 9.48 29.07 32.56 morestat() # Min. 1st Qu. Median Mean 3rd Qu. Max. # 0.00 43.43 66.00 58.32 80.80 100.00 # The brown dots are 5^ and 95^ percentiles # The red dot is the mean # If I write noMean=1; morestat() the mean is not shown. # With noGrid=1 I have: BF=4; HF=2.5; noGrid=1; noMean=1; histoclas(interv,freq) In addition to the mean, some percentiles (the 25th, 50th and 75th percentiles, or first quartile, median, and third quartile) are estimated and the box-plot is drawn. [ to do this, a lot of data - distributed as the histogram - was generated; the file is dataclas; you do not have to see it; if you want to have an idea of it you can use str(dataclas) ] The percentiles are also called 100-quantiles The unitary percentage frequencies are the percentage frequencies divided by the amplitude of each interval, so that the area of each rectangle represents the relative frequency of the outputs that fall in the interval that is the base. The sum of the areas of the rectangles is 1, or 100%. For other percentiles you must use percentile(n). For example, the width of the box (difference between 75th and 25th percentile, ie distance between 1st and 3th quartile) is: percentile(75) - percentile(25) # 37.3752 This value [ percentile(75) - percentile(25) = 3^quartile - 1^quartile ] is also an indicator of the data dispersion. Another used index is the standard deviation Sd, that is the root mean square. If the data are X1, , Xn and the mean is M, Sd is √( ( (X1-M)^2 + + (Xn-M)^2 ) / n ) In this case: Sd(dataclas) # 30.05867 Often in place of Sd we use √ Var (variance), where Var = (X1-M)^2 + + (Xn-M)^2 Another example: thoracic circumference of 3-year-old European children (1970) # 3th percentile is 48.9, 10th is 49.9, 25th is 51, 50th is 52.4, # 75th is 54.1, 90th is 55.8, 97th is 57.9 # To make the histogram I assume that minimum and maximum are 47 and 60 interv = c(47, 48.9, 49.9, 51.0, 52.4, 54.1, 55.8, 57.9, 60) freq = c( 3, 7, 15, 25, 25, 15, 7, 3 ) BF=5.5; HF=3 histoclas(interv,freq) morestat() If I have a set of data XXX I can compute the percentiles with Percentile(XXX,n): data = c(1,2,2,3,3,3,4,4,4,4,4,5,5,6,7,8,8) median(data); Percentile(data,50); Percentile(data,15); Percentile(data,90) # 4 4 2.4 7.4 If we want to give an index of the dispersion of the data: Percentile(data,75)-Percentile(data,25) # 2 or: Sd(data) # 1.963332 # For histogram and boxplot use: histogram(data); morestat()