Documentation:Adding Titles to graphs and plots.
> AirQualityIndex <- read.csv(“Filename”, header=TRUE, stringsAsFactors=FALSE) - Records Data into a table called AirQualityIndex
> AQI=AirQualityIndex$AQI.O3 - Set AQI array to data in column AQI.03
> range(AQI) - view the smallest and largest values in the AQI array [1] 8 49
> breaks=seq(8,50,by=6) - Create an array of values broken into intervals of 6 beginning at 8, then 14,…
> AQI.cut=cut(AQI,breaks,right=F) - Data is classified into intervals using the cut argument
> AQI.freq=table(AQI.cut) - Summarizes data, counting the frequency of data per interval
> AQI.freq AQI.cut [8,14) [14,20) [20,26) [26,32) [32,38) [38,44) [44,50) 5 12 10 4 3 1 1
Outputs the the freqency of values per interval
> nrow(AirQualityIndex) - Row count of values. [1] 36Row
> AQI.relfreq=AQI.freq/(nrow(AirQualityIndex)) - Calculate the percentage of values per interval divide the interval count by the total number of rows
> AQI.relfreq AQI.cut [8,14) [14,20) [20,26) [26,32) [32,38) [38,44) [44,50) 0.13888889 0.33333333 0.27777778 0.11111111 0.08333333 0.02777778 0.02777778 > nrow(AirQualityIndex) [1] 36 > midpoints.breaks=seq(11,47,by=6) > midpoints.breaks [1] 11 17 23 29 35 41 47 > plot(midpoints.breaks,AQI.relfreq, - plot the data x is midpoints.breaks, y is AQI.relfreq + main=”Air Quality Index, Sudbury Ontario”, - labels the graph + xlab=”Daily Ozone Readings”, - labels xaxis + ylab=”Relative Frequency”) - labels yaxis > lines(midpoints.breaks,AQI.relfreq) - connects the dots with lines > axis(side=2) # display y-axis values