The heat map is a graphical representation of data where the individual values contained in a matrix are represented as colors. -- From Wikipedia, the free encyclopedia Heat map is a common statistical gragph, which tries to show the status of interactive inforamtion of two discrete variables and maps those information based on the continuous varibales. See how it works:

Data Simulation

Semester <- rep(c("S1","S2","S3"),times=12)
Weight <- runif(n = 36,min = 50, max = 70)
Class <- rep(1:12,each=3)
weightdf <- data.frame(Class = as.factor(Class), Semester = Semester, Weight = Weight )

Just create a data frame about the mean weight of 12 classes in 3 semesters.

head(weightdf,n=6)
##   Class Semester   Weight
## 1     1       S1 50.44415
## 2     1       S2 56.03688
## 3     1       S3 66.73933
## 4     2       S1 67.41748
## 5     2       S2 63.33792
## 6     2       S3 65.16199

1. ggplot2()

It's avaliable to use ggplot2 package to plot heatmap

library(ggplot2)
ggplot(weightdf,aes(x= Class, y = Semester,fill=Weight))+geom_raster()
plot of chunk unnamed-chunk-3

or

ggplot(weightdf,aes(x= Class, y = Semester,fill=Weight))+geom_tile()
plot of chunk unnamed-chunk-4

So from the graphs above, we could see the lighter color represents the heavier weight. ps. In this case, using geom_raster() or geom_tile() won't affect the final results, but usually geom_raster() is the more efficient one.

2. heatmap()

Actually, we can also use 'heatmap()' function to plot a heat map directly, but this method requires the target data be numeric matrix.

matrixx <- matrix(runif(100,1,100),5,20)
heatmap(matrixx)
plot of chunk unnamed-chunk-5