Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing tidyverse install from ggplot lesson #243

Merged
merged 4 commits into from
Dec 13, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions episodes/06-data-visualization.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ variants = read.csv("https://raw.githubusercontent.com/naupaka/vcfr-for-data-car

<img src="https://ggplot2.tidyverse.org/logo.png" align="right" alt="Line plot enclosed in hexagon shape with ggplot2 typed beneath and www.rstudio.com at the bottom.">

**`ggplot2`** is a plotting package that makes it simple to create complex plots from data in a data frame. It provides a more programmatic interface for specifying what variables to plot, how they are displayed, and general visual properties. Therefore, we only need minimal changes if the underlying data change or if we decide to change from a bar plot to a scatter plot. This helps in creating publication-quality plots with minimal amounts of adjustments and tweaking.
**`ggplot2`** is a plotting package, part of the tidyverse,
that makes it simple to create complex plots from data in a data frame. It provides a more programmatic interface for specifying what variables to plot, how they are displayed, and general visual properties. Therefore, we only need minimal changes if the underlying data change or if we decide to change from a bar plot to a scatter plot. This helps in creating publication-quality plots with minimal amounts of adjustments and tweaking.

The **gg** in "**ggplot**" stands for "**G**rammar of **G**raphics," which is an elegant yet powerful way to describe the making of scientific plots. In short, the grammar of graphics breaks down every plot into a few components, namely, a dataset, a set of geoms (visual marks that represent the data points), and a coordinate system. You can imagine this is a grammar that gives unique names to each component appearing in a plot and conveys specific information about data. With **ggplot**, graphics are built step by step by adding new elements.

Expand All @@ -55,18 +56,27 @@ The idea of **mapping** is crucial in **ggplot**. One familiar example is to *ma

## Installing `tidyverse`

**`ggplot2`** belongs to the [**`tidyverse`** framework](https://www.tidyverse.org/). Therefore, we will start with loading the package **`tidyverse`**. If **`tidyverse`** is not already installed, then we need to install first. If it is already installed, then we can skip the following step:
First, we need to install the `ggplot2` package.

```{r install-tidyverse, echo=TRUE, eval=FALSE}
sstevens2 marked this conversation as resolved.
Show resolved Hide resolved
install.packages("tidyverse") # Installing tidyverse package, includes ggplot2 and other packages such as dplyr, readr, tidyr
install.packages("ggplot2")
```

Now, let's load the `tidyverse` package:
Now, let's load the `ggplot2` package:

```{r load-tidyverse}
sstevens2 marked this conversation as resolved.
Show resolved Hide resolved
library(tidyverse)
library(ggplot2)
```

We will also re-use some of the other tidyverse packages we used in the last episode, so we need to load them as well.
sstevens2 marked this conversation as resolved.
Show resolved Hide resolved

```{r load-tidyverse}
sstevens2 marked this conversation as resolved.
Show resolved Hide resolved
library(readr)
library(dplyr)
```



As we can see from above output **`ggplot2`** has been already loaded along with other packages as part of the **`tidyverse`** framework.

## Loading the dataset
Expand Down
Loading