InfluentialPoints.com
Biology, images, analysis, design...
Use/Abuse Principles How To Related
"It has long been an axiom of mine that the little things are infinitely the most important" (Sherlock Holmes)

Search this site

 

 

Just a note

Frequency can be expressed as the absolute frequency (as shown in the first graph), or the relative frequency, expressed as a proportion or percentage (as shown in the second graph).

If these observations are an unbiased sample, each class provides an estimate of the proportion of the population sampled lying within that interval. The more common each class is within its population, the more probable it is an observation will fall in that class.

The following code produces much the same sort of result using R.

 

  • To plot a number of histograms on the same graph, as we have done here, you need to change the plotting defaults using 'par'. To plot 2 graphs with 1 row and 2 columns, we used par(mfrow=c(1,2)). To plot 4 graphs, use: par(mfcol = c(2, 2)).

  • Since it is easy to forget how to change them back afterwards, it is wise to make a copy of them first, using: defaults=par() Then, when you want to revert to the usual display, you can use this instruction: par(defaults) Alternatively just reset values using par(mfcol=c(1,1)). When you quit R, it will automatically reset to the default values.

  • By default R will set the number of breaks using an algorithm to optimise the number of cells. We instead specified that we wanted breaks every 20 units from 380 to 600 using the instruction breaks=seq(380,600,20). Alternatively you can specify the total number (n) of breaks using breaks=n. Labels have been inserted using , main='Histogram' for the main heading, ylab='Relative frequency for the y-axis title and xlab='Weight' for the x-axis title. Colour is set with col='blue'

  • 'hist' does not itself plot relative frequencies, but instead plots probability densities such that the total area of the histogram is equal to one. However, a relative frequency histogram can be plotted in the following way. h=histogram(wta),plot=FALSE instructs R to copy the results of the hist function into a 'data frame' variable called h, but not to plot the histogram. h$counts=h$counts/sum(h$counts) tells R to extract the frequencies from the histogram variable called h, calculate the relative frequencies, and put the resulting set of values back where they came from. They are then plotted using plot(h) with labelling as before.

    For more information on how to use the hist function, use this instruction: ?hist