Documentation:Ploting a Histogram in R

From UBC Wiki

> x <- read.table(“Filename”,header=F) - Copies a table of data from a file called "Filename", must be the full File name. Header=F records
> y = x1 - Extracts the value of the first column of x and saves the value to a 1-D array called y
> y
[1] 8848 8611 8586 8511 8463 8201 8167 8163 8125 8091 8068 8047 8035 8012 7885 7852 7820 7816 7815
[20] 7788 7785 7756 7756 7756 7756 7742 7723 7720 7719 7690 7654 7619 7555 7553 7546 7495 7485 7439
[39] 7406 7398 7313 7291 7285 7273 7245 7150 7142 7135 7134 7129 - output values of the array y
> range(y) - range of values from smallest to largest in the array y
[1] 7129 8848
> hist(y,breaks=seq(7000,8900,by=(8900-7000)/7),axes=F,ylim=c(0,20)) - Creates and plots the histogram, The first argument of hist takes the the data to be plotted, breaks takes a sequence of values to seperate the bins, axes is set to false, and ylim creates the range in the y axis
> axis(side=1,at=seq(7000,8900,by=round((8900-7000)/7))) - add x-axis with interval values
> axis(side=2) - add x-axis
>

The image shows the histogram created from the following code.