This is third and final blog post for base graph in R.

boxplot

library(datasets)
data("airquality")
attach(airquality)
boxplot(Temp,main="boxplot of temperature")

### Histogram

hist(Temp, main="Histogram of Temperature", col="blue")

hist(Solar.R,main="Histogram of Solar Radiation", breaks= 10,col="red")

### Add a Normal curve to Histogram of Solar Radiation

xfit <-seq(min(Solar.R, na.rm= T), max(Solar.R, na.rm =T), length=350)
yfit <- dnorm(xfit, mean=mean(Solar.R, na.rm=T),sd=sd(Solar.R, na.rm = T))
yfit <- yfit*diff(hist(Solar.R,main="Histogram of Solar Radiation", breaks= 10,col="red")$mids[1:2])*length(Solar.R)
lines(xfit,yfit,col ="blue",lwd=2)

### Density plot: Kernel density plots are usually a much more effective way to view the distribution of a variable and filling the density plot.

plot(density(Solar.R, na.rm = T), col ="blue", main ="kernel Density of Solar Radiation")
polygon(density(Solar.R, na.rm = T), col ="violet", border= "blue")

### Simple Bar plot

par(mfcol=c(1,2))
data("iris")
head(iris)
##   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1          5.1         3.5          1.4         0.2  setosa
## 2          4.9         3.0          1.4         0.2  setosa
## 3          4.7         3.2          1.3         0.2  setosa
## 4          4.6         3.1          1.5         0.2  setosa
## 5          5.0         3.6          1.4         0.2  setosa
## 6          5.4         3.9          1.7         0.4  setosa
seplen <- table(iris$Sepal.Length)
barplot(seplen,main="Sepal length frequency ", xlab="Sepal length")

# Horizontal Plot

barplot(seplen,main="Sepal length frequency ", ylab="Sepal length", horiz = T)

# pie chart

library("plyr")
v <- count(iris,"Species")
pie(v$freq, labels=v$Species, main ="pie chart of spicies used in the test")