How to create heatmap plot in R?

Description

To create heatmap plot using R programming.

  • Mainly used for Cluster analysis.
  • It substitutes numbers with coloured cells
  • R Package :gplots
  • R Function : heatmap(x, scale=, xlab= ,ylab= , main= ,col= )
  • x : Data set(mtcars)
  • Scale : character indicating if the valuesshould be  centered and scaled ineither the row direction or  thecolumn direction, or none.
  • xlab : Label for x
  • ylab : Label for y
  • main : title of the graph

#Heat Map
#Input
attach(mtcars)
input<-as.matrix(mtcars)

#heatmap
heatmap(input)

#Adding Scale and Labels
heatmap(input,scale=”column”,xlab = “Variable”,ylab = “Car Model”,main=”Heatmap Plot”)

#Changing color
heatmap(input,scale=”column”,xlab = “Variable”,ylab = “Car Model”,main=”Heatmap Plot”,col=terrain.colors(256))

Leave Comment

Your email address will not be published. Required fields are marked *

clear formSubmit