From 74703c8e238aaeac4df941f912496bd9a7edcaec Mon Sep 17 00:00:00 2001 From: Sarah Stevens Date: Mon, 4 Dec 2023 16:28:04 -0600 Subject: [PATCH 1/4] Removing tidyverse install from ggplot lesson fixes #237 --- episodes/06-data-visualization.Rmd | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/episodes/06-data-visualization.Rmd b/episodes/06-data-visualization.Rmd index 8a07701c..d7106f85 100644 --- a/episodes/06-data-visualization.Rmd +++ b/episodes/06-data-visualization.Rmd @@ -45,7 +45,8 @@ variants = read.csv("https://raw.githubusercontent.com/naupaka/vcfr-for-data-car 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, that is 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. @@ -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} -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} -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. + +```{r load-tidyverse} +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 From 5a6f136d94fa07c7a7fbc1fc92e997c0588b44ba Mon Sep 17 00:00:00 2001 From: Sarah Stevens Date: Mon, 4 Dec 2023 16:31:58 -0600 Subject: [PATCH 2/4] Update episodes/06-data-visualization.Rmd --- episodes/06-data-visualization.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/episodes/06-data-visualization.Rmd b/episodes/06-data-visualization.Rmd index d7106f85..f2d587e8 100644 --- a/episodes/06-data-visualization.Rmd +++ b/episodes/06-data-visualization.Rmd @@ -45,7 +45,7 @@ variants = read.csv("https://raw.githubusercontent.com/naupaka/vcfr-for-data-car Line plot enclosed in hexagon shape with ggplot2 typed beneath and www.rstudio.com at the bottom. -**`ggplot2`** is a plotting package, that is part of the tidyverse, +**`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. From 83727def7b5088c1010f8d1312aebc3a707502d5 Mon Sep 17 00:00:00 2001 From: Sarah Stevens Date: Mon, 4 Dec 2023 16:33:32 -0600 Subject: [PATCH 3/4] Update episodes/06-data-visualization.Rmd --- episodes/06-data-visualization.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/episodes/06-data-visualization.Rmd b/episodes/06-data-visualization.Rmd index f2d587e8..3ce66534 100644 --- a/episodes/06-data-visualization.Rmd +++ b/episodes/06-data-visualization.Rmd @@ -68,7 +68,7 @@ Now, let's load the `ggplot2` package: 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. +We will also use some of the other tidyverse packages we used in the last episode, so we need to load them as well. ```{r load-tidyverse} library(readr) From 76a7b8b11ab6f10e2dad883e7bc8475a7734f26e Mon Sep 17 00:00:00 2001 From: Sarah Stevens Date: Mon, 4 Dec 2023 16:40:45 -0600 Subject: [PATCH 4/4] Fixing chunk labels --- episodes/06-data-visualization.Rmd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/episodes/06-data-visualization.Rmd b/episodes/06-data-visualization.Rmd index 3ce66534..76ff260a 100644 --- a/episodes/06-data-visualization.Rmd +++ b/episodes/06-data-visualization.Rmd @@ -58,19 +58,19 @@ The idea of **mapping** is crucial in **ggplot**. One familiar example is to *ma First, we need to install the `ggplot2` package. -```{r install-tidyverse, echo=TRUE, eval=FALSE} +```{r install-ggplot2, echo=TRUE, eval=FALSE} install.packages("ggplot2") ``` Now, let's load the `ggplot2` package: -```{r load-tidyverse} +```{r load-ggplot2} library(ggplot2) ``` We will also use some of the other tidyverse packages we used in the last episode, so we need to load them as well. -```{r load-tidyverse} +```{r load-other-pkgs} library(readr) library(dplyr) ```