Name | Last modified | Size | Description | |
---|---|---|---|---|
Parent Directory | - | |||
data/ | 2024-03-20 17:05 | - | ||
figures/ | 2024-03-20 17:05 | - | ||
slides/ | 2024-03-20 17:06 | - | ||
data-visualization-m..> | 2018-09-21 08:44 | 205 | ||
Heatmaps.Rmd | 2018-09-21 06:03 | 6.0K | ||
working_script.R | 2018-09-21 14:49 | 9.2K | ||
Heatmaps_all.Rmd | 2018-09-19 13:26 | 11K | ||
ggplot_plotly.Rmd | 2020-02-24 14:48 | 20K | ||
Denisty_Histogram.png | 2018-09-21 11:59 | 1.0M | ||
ggplot2_cheatsheet.pdf | 2018-09-19 13:26 | 1.6M | ||
Heatmaps.html | 2018-09-21 06:03 | 2.4M | ||
Heatmaps_all.html | 2018-09-19 13:26 | 6.5M | ||
ggplot_plotly.html | 2020-02-24 14:49 | 8.6M | ||
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:
%>%
, sends the object to the next command (function, etc.). It always goes forward.%<>%
, sends the object forward and receives the final result from the end of the pipeline and saves it into the object on the left-side of the pipe, i.e. the object from which the compound assignment pipe-operator had started in the first place. In other words, this is a bilateral pipe.Supplementary resources
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:
d3heatmap
, ComplexHeatmap
, pheatmap
, superheat
Any ggplot
object can be transformed into a plotly object by: plotly::ggplotly(p)
.
aes(text = paste("country:", country))
or aes(col="country")
. Example here: https://plot.ly/~MattSundquist/19612/africa-americas-asia-europe-oceania/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.