Heatmaps
Learn how to build and customize heatmaps in ggplot2.
Introduction to heatmaps
Heatmaps are graphical representations of data where the values are represented as colors. They are a valuable tool for visualizing and understanding large datasets, as they can help identify patterns and trends in the data. In ggplot2, heatmaps can be created using the geom_tile() function.
Let’s first create a numerical matrix in R using the rnorm function, as shown in the code below:
- Line 1: We set the
seedparameter as123to reproduce the same set of random numbers every time we run the code. - Line 2: We create a matrix named
musing thematrix()function with rows and columns specified by the argumentsnrow=5andncol=5, respectively. We generate