Skip to content

Commit

Permalink
Merge branch 'main' into 824-bullet-formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ErinBecker authored Apr 24, 2023
2 parents 613393a + 6591833 commit eb4ef19
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
29 changes: 16 additions & 13 deletions 00-before-we-start.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,18 @@ source("setup.R")
The term "`R`" is used to refer to both the programming language and the
software that interprets the scripts written using it.

[RStudio](https://rstudio.com) is currently a very popular way to not only write
your R scripts but also to interact with the R software. To function correctly,
RStudio needs R and therefore both need to be installed on your computer.
[RStudio](https://rstudio.com) is a popular way to write R scripts and interact with the R software.
To function correctly, RStudio needs R and therefore both need to be installed on your computer.

## Why learn R?

### R does not involve lots of pointing and clicking, and that's a good thing

The learning curve might be steeper than with other software, but with R, the
results of your analysis do not rely on remembering a succession of pointing and
clicking, but instead on a series of written commands, and that's a good thing!
In R, the results of your analysis rely on a series of written commands, and not
on remembering a succession of pointing and clicking. That is a good thing!
So, if you want to redo your analysis because you collected more data, you don't
have to remember which button you clicked in which order to obtain your results.
With a stored series of commands (this is your script), you can repeat running them and
With a stored series of commands in an R script, you can repeat running them and
R will process the new dataset exactly the same way as before.

Working with scripts makes the steps you used in your analysis clear, and the
Expand All @@ -58,15 +56,16 @@ doing, and facilitates your learning and comprehension of the methods you use.

### R code is great for reproducibility

Reproducibility is when someone else (including your future self) can obtain the
Reproducibility is when someone else, including your future self, can obtain the
same results from the same dataset when using the same analysis.

R integrates with other tools to generate manuscripts from your code. If you
collect more data, or fix a mistake in your dataset, the figures and the
statistical tests in your manuscript are updated automatically.

An increasing number of journals and funding agencies expect analyses to be
reproducible, so knowing R will give you an edge with these requirements.
R is widely used in academia and in industries such as pharma and biotech.
These organisations expect analyses to be reproducible, so knowing R will give you an
edge with these requirements.

### R is interdisciplinary and extensible

Expand All @@ -90,14 +89,18 @@ computer or on the web.

### R produces high-quality graphics

The plotting functionalities in R are endless, and allow you to adjust any
aspect of your graph to convey most effectively the message from your data.
The plotting functionalities in R are endless, and allow you to adjust any
aspect of your graph to visualize your data more effectively.


### R has a large and welcoming community

Thousands of people use R daily. Many of them are willing to help you through
mailing lists and websites such as [Stack Overflow](https://stackoverflow.com/),
or on the [RStudio community](https://community.rstudio.com/).
[RStudio community](https://community.rstudio.com/), and Slack channels such as
the R for Data Science online community (https://www.rfordatasci.com/). In addition,
there are numerous online and in person meetups organised globally through organisations
such as R Ladies Global (https://rladies.org/).

### Not only is R free, but it is also open-source and cross-platform

Expand Down
4 changes: 2 additions & 2 deletions 03-dplyr.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ The `count()` function is shorthand for something we've already seen: grouping b
```{r, purl = FALSE}
surveys %>%
group_by(sex) %>%
summarise(count = n())
summarize(count = n())
```

For convenience, `count()` provides the `sort` argument:
Expand Down Expand Up @@ -543,7 +543,7 @@ the value provided.

Let's use `pivot_wider()` to transform surveys to find the mean weight of each
genus in each plot over the entire survey period. We use `filter()`,
`group_by()` and `summarise()` to filter our observations and variables of
`group_by()` and `summarize()` to filter our observations and variables of
interest, and create a new variable for the `mean_weight`.

```{r, purl=FALSE}
Expand Down
11 changes: 7 additions & 4 deletions 04-visualization-ggplot2.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,14 @@ ggplot(data = surveys_complete, mapping = aes(x = species_id, y = weight)) +
```

By adding points to the boxplot, we can have a better idea of the number of
measurements and of their distribution:
measurements and of their distribution. Because the boxplot will show the outliers
by default these points will be plotted twice -- by `geom_boxplot` and
`geom_jitter`. To avoid this we must specify that no outliers should be added
to the boxplot by specifying `outlier.shape = NA`.

```{r boxplot-with-points, purl=FALSE}
ggplot(data = surveys_complete, mapping = aes(x = species_id, y = weight)) +
geom_boxplot(alpha = 0) +
geom_boxplot(outlier.shape = NA) +
geom_jitter(alpha = 0.3, color = "tomato")
```

Expand Down Expand Up @@ -596,7 +599,7 @@ ggplot(surveys_complete, aes(x = species_id, y = hindfoot_length)) +
> * See if you can change the thickness of the lines.
> * Can you find a way to change the name of the legend? What about its labels?
> * Try using a different color palette (see
> <https://www.cookbook-r.com/Graphs/Colors_(ggplot2)/>).
> <https://r-graphics.org/chapter-colors>).
## Arranging plots

Expand Down Expand Up @@ -677,7 +680,7 @@ saved plot.
## minutes to either improve one of the plots generated in this
## exercise or create a beautiful graph of your own. Use the RStudio
## ggplot2 cheat sheet for inspiration:
## https://www.rstudio.com/wp-content/uploads/2015/08/ggplot2-cheatsheet.pdf
## https://posit.co/wp-content/uploads/2022/10/data-visualization-1.pdf
```

```{r, child="_page_built_on.Rmd"}
Expand Down
2 changes: 1 addition & 1 deletion before_body.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<a href='https://carpentries.github.io/workbench'>The Carpentries Workbench</a>:
<a href="https://preview.carpentries.org/R-ecology-lesson">https://preview.carpentries.org/R-ecology-lesson</a>.
<br>
<b>The Workbench version of this lesson will become default on 2023-01-23</b>.
<b>The Workbench version of this lesson will become default on 2023-05-01</b>.
<button type="button" style="border: true; position: absolute; top: 0px; right: 50px; color: #383838;" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true" style='font-size:34pt'>&times;</span>
</button>
Expand Down

0 comments on commit eb4ef19

Please sign in to comment.