Index of /R/2018/material/data-visualization-module

[ICO]NameLast modifiedSizeDescription

[PARENTDIR]Parent Directory   -  
[TXT]ggplot_plotly.html 2020-02-24 14:49 8.6M 
[TXT]Heatmaps_all.html 2018-09-19 13:26 6.5M 
[TXT]Heatmaps.html 2018-09-21 06:03 2.4M 
[   ]ggplot2_cheatsheet.pdf 2018-09-19 13:26 1.6M 
[IMG]Denisty_Histogram.png 2018-09-21 11:59 1.0M 
[TXT]ggplot_plotly.Rmd 2020-02-24 14:48 20K 
[TXT]Heatmaps_all.Rmd 2018-09-19 13:26 11K 
[TXT]working_script.R 2018-09-21 14:49 9.2K 
[TXT]Heatmaps.Rmd 2018-09-21 06:03 6.0K 
[   ]data-visualization-m..>2018-09-21 08:44 205  
[DIR]slides/ 2024-03-20 17:06 -  
[DIR]figures/ 2024-03-20 17:05 -  
[DIR]data/ 2024-03-20 17:05 -  

Interlude

Pipes in R originate from a package called magrittr (pronounce with sophistacated French accent). The name of the package is, of course, an homage to the Belgian surrealist painter René Magritte. The word pipe itself is a tribute to one of his paintings, The Treachery of Images (La Trahison des images), also known as This Is Not A Pipe. At the same time it is a nod to pipes in Unix-like (Ubuntu, Arch Linux, Mac OS, etc.) operating systems, or in other words telling us that pipes in R are not truly pipes.

Pipes are used for pipelining.

There are four pipes in magrittr. Two of the most useful ones are:


Supplementary resources


ggplot2

Fundamentals of dplyr and tidyr are essential for this section of the course. We will specifically make extensive use of functons such as filter, select, melt, and gather and transform the dataset from wide to long format or vice versa.

A list of topics that are covered:

  1. The introduction can perhaps start off by a brief comparison between ‘base’ R plotting functions and ggplot2.
  2. Saving plots: ggsave, png, pdf, dev.off
  3. Extra themes: ggthemes, ggthemr

Heatmaps


Plotly

Any ggplot object can be transformed into a plotly object by: plotly::ggplotly(p).


Warnings

ggplot
1. In multi-line ggplot2 codes, + sign must be always placed at the end of the line, otherwise the code results in an error.
2. aes(color = "red") maps color to a column named red, to change color of all points, use color = outside of aes
3. Writing the mapping directly inside the aes of ggplot function (instead of specifying in e.g. geom_point) has the advantage that the mapping will be passed to all other geoms (e.g. geom_smooth, etc.). But if you write the mapping only inside ‘geom_point’, then you have to specifying mapping inside geom_smooth once again.

Books