Skip to content

Commit

Permalink
differences for PR #871
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 21, 2023
1 parent 6cd9317 commit 1e23eca
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 1,229 deletions.
48 changes: 24 additions & 24 deletions 01-rstudio-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ source: Rmd

::::::::::::::::::::::::::::::::::::::: objectives

- Describe the purpose and use of each pane in RStudio
- Locate buttons and options in RStudio
- Describe the purpose and use of each pane in the RStudio IDE
- Locate buttons and options in the RStudio IDE
- Define a variable
- Assign data to a variable
- Manage a workspace in an interactive R session
Expand All @@ -29,39 +29,38 @@ source: Rmd



## Motivation

Science is a multi-step process: once you've designed an experiment and collected
data, the real fun begins! This lesson will teach you how to start this process using
R and RStudio. We will begin with raw data, perform exploratory analyses, and learn
how to plot results graphically. This example starts with a dataset from
[gapminder.org](https://www.gapminder.org) containing population information for many
countries through time. Can you read the data into R? Can you plot the population for
Senegal? Can you calculate the average income for countries on the continent of Asia?
By the end of these lessons you will be able to do things like plot the populations
for all of these countries in under a minute!

## Before Starting The Workshop

Please ensure you have the latest version of R and RStudio installed on your machine. This is important, as some packages used in the workshop may not install correctly (or at all) if R is not up to date.

- [Download and install the latest version of R here](https://www.r-project.org/)
- [Download and install RStudio here](https://www.rstudio.com/products/rstudio/download/#download)

## Introduction to RStudio

## Why use R and R studio?

Welcome to the R portion of the Software Carpentry workshop!

Science is a multi-step process: once you've designed an experiment and collected
data, the real fun begins with analysis! Throughout this lesson, we're going to teach you some of the fundamentals of the R language as well as some best practices for organizing code for scientific projects that will make your life easier.

Although we could use a spreadsheet in Microsoft Excel or Google sheets to analyze our data, these tools are limited in their flexibility and accessibility. Critically, they also are difficult to share steps which explore and change the raw data, which is key to ["reproducible" research](https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1003285).
Welcome to the R portion of the Software Carpentry workshop.

Therefore, this lesson will teach you how to begin exploring your data using R and RStudio. The R program is available for Windows, Mac, and Linux operating systems, and is a freely-available where you downloaded it above. To run R, all you need is the R program.
Throughout this lesson, we're going to teach you some of the fundamentals of
the R language as well as some best practices for organizing code for
scientific projects that will make your life easier.

However, to make using R easier, we will use the program RStudio, which we also downloaded above. RStudio is a free, open-source, Integrated Development
We'll be using RStudio: a free, open-source R Integrated Development
Environment (IDE). It provides a built-in editor, works on all platforms (including
on servers) and provides many advantages such as integration with version
control and project management.

## Overview

We will begin with raw data, perform exploratory analyses, and learn how to plot results graphically. This example starts with a dataset from [gapminder.org](https://www.gapminder.org) containing population information for many
countries through time. Can you read the data into R? Can you plot the population for
Senegal? Can you calculate the average income for countries on the continent of Asia?
By the end of these lessons you will be able to do things like plot the populations
for all of these countries in under a minute!


**Basic layout**

When you first open RStudio, you will be greeted by three panels:
Expand Down Expand Up @@ -159,7 +158,8 @@ the first element of the line being printed in the console. For more information
on indexing vectors, see [Episode 6: Subsetting Data](https://swcarpentry.github.io/r-novice-gapminder/06-data-subsetting/index.html).

If you type in an incomplete command, R will wait for you to
complete it. If you are familiar with Unix Shell's bash, you may recognize this behavior from bash.
complete it. If you are familiar with Unix Shell's bash, you may recognize this
behavior from bash.

```r
> 1 +
Expand Down Expand Up @@ -543,7 +543,7 @@ min-length
One final thing to be aware of is that R is *vectorized*, meaning that
variables and functions can have vectors as values. In contrast to physics and
mathematics, a vector in R describes a set of values in a certain order of the
same data type. For example:
same data type. For example


```r
Expand Down Expand Up @@ -643,7 +643,7 @@ function (name, pos = -1L, envir = as.environment(pos), all.names = FALSE,
}
else all.names
}
<bytecode: 0x5585826948e8>
<bytecode: 0x55a721b57928>
<environment: namespace:base>
```

Expand Down
4 changes: 2 additions & 2 deletions 02-project-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ Now we have a good directory structure we will now place/save the data file in t

## Challenge 3

Download the gapminder data from [this link to a csv file](data/gapminder_data.csv).
Download the gapminder data from [here](data/gapminder_data.csv).

1. Download the file (right mouse click on the link above -> "Save link as" / "Save file as", or click on the link and after the page loads, press <kbd>Ctrl</kbd>\+<kbd>S</kbd> or choose File -> "Save page as")
2. Make sure it's saved under the name `gapminder_data.csv`
Expand Down Expand Up @@ -190,7 +190,7 @@ ls -lh data/gapminder_data.csv
```

```{.output}
-rw-r--r-- 1 runner docker 80K Nov 21 00:11 data/gapminder_data.csv
-rw-r--r-- 1 runner docker 80K Nov 21 00:14 data/gapminder_data.csv
```

The file size is 80K.
Expand Down
4 changes: 2 additions & 2 deletions 03-seeking-help.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.3.2 tools_4.3.2 yaml_2.3.7 knitr_1.45 xfun_0.41
[6] renv_1.0.3 evaluate_0.23
[1] compiler_4.3.2 tools_4.3.2 rstudioapi_0.15.0 yaml_2.3.7
[5] knitr_1.43 xfun_0.40 renv_1.0.3 evaluate_0.21
```

Will print out your current version of R, as well as any packages you
Expand Down
2 changes: 1 addition & 1 deletion 08-plot-ggplot2.md
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ There are two nice things about `ggsave`. First, it defaults to the last plot, s

This is a taste of what you can do with ggplot2. RStudio provides a
really useful [cheat sheet][cheat] of the different layers available, and more
extensive documentation is available on the [ggplot2 website][ggplot-doc]. All RStudio cheat sheets are available from the [RStudio website][cheat_all].
extensive documentation is available on the [ggplot2 website][ggplot-doc]. All RStudio cheat sheets can be found [here][cheat_all].
Finally, if you have no idea how to change something, a quick Google search will
usually send you to a relevant question and answer on Stack Overflow with reusable
code to modify!
Expand Down
6 changes: 3 additions & 3 deletions 13-dplyr.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@ do these operations using the normal base R operations:


```r
mean(gapminder$gdpPercap[gapminder$continent == "Africa"])
mean(gapminder[gapminder$continent == "Africa", "gdpPercap"])
```

```{.output}
[1] 2193.755
```

```r
mean(gapminder$gdpPercap[gapminder$continent == "Americas"])
mean(gapminder[gapminder$continent == "Americas", "gdpPercap"])
```

```{.output}
[1] 7136.11
```

```r
mean(gapminder$gdpPercap[gapminder$continent == "Asia"])
mean(gapminder[gapminder$continent == "Asia", "gdpPercap"])
```

```{.output}
Expand Down
2 changes: 1 addition & 1 deletion 14-tidyr.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Until now, we've been using the nicely formatted original gapminder dataset, but
'real' data (i.e. our own research data) will never be so well organized. Here
let's start with the wide formatted version of the gapminder dataset.

> Download the wide version of the gapminder data from [this link to a csv file](data/gapminder_wide.csv)
> Download the wide version of the gapminder data from [here](data/gapminder_wide.csv)
> and save it in your data folder.
We'll load the data file and look at it. Note: we don't want our continent and
Expand Down
4 changes: 2 additions & 2 deletions 15-knitr-markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ You can make a hyperlink like this:

You can include an image file like this: `![The Carpentries Logo](https://carpentries.org/assets/img/TheCarpentries.svg)`

You can do subscripts (e.g., F~2~) with `F~2~` and superscripts (e.g.,
You can do subscripts (e.g., F~~2~~) with `F~2~` and superscripts (e.g.,
F^2^) with `F^2^`.

If you know how to write equations in
Expand Down Expand Up @@ -447,7 +447,7 @@ transformed to the formatted appearance (**bold words**) as you type.
This mode also includes a toolbar at the top with basic formatting buttons,
similar to what you might see in common word processing software programs.
You can turn visual editing on and off by pressing
the ![](fig/visual_mode_icon.png){alt='Icon for turning on and off the visual editing mode in RStudio, which looks like a pair of compasses'}
the ![](fig/visual_mode_icon.png)
button in the top right corner of your R Markdown document.

::::::::::::::::::::::::::::::::::::::::::::::::::
Expand Down
96 changes: 0 additions & 96 deletions config.yaml

This file was deleted.

Empty file modified fig/06-rmd-generate-figures.sh
100755 → 100644
Empty file.
Empty file modified fig/12-plyr-generate-figures.sh
100755 → 100644
Empty file.
15 changes: 15 additions & 0 deletions instructor-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,21 @@ To prevent the learners from having to re-enter their password each time they pu
$ git config --global credential.helper 'cache --timeout=10000000'
```

## RStudio Color Preview

RStudio has a feature to preview the color for certain named colors and hexadecimal colors. This may confuse or distract learners (and instructors) who are not expecting it.

Mainly, this is likely to come up during the episode on "Data Structures" with the following code block:

```r
cats <- data.frame(coat = c("calico", "black", "tabby"),
weight = c(2.1, 5.0, 3.2),
likes_string = c(1, 0, 1))
```

This option can be turned off an on in the following menu setting:
Tools -> Global Options -> Code -> Display -> Enable preview of named and hexadecimal colors (under "Syntax")

## Pulling in Data

The easiest way to get the data used in this lesson during a workshop is to have
Expand Down
18 changes: 9 additions & 9 deletions md5sum.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
"LICENSE.md" "b24ebbb41b14ca25cf6b8216dda83e5f" "site/built/LICENSE.md" "2023-11-21"
"config.yaml" "810028d39c377c82aef9239cb1ec0dd3" "site/built/config.yaml" "2023-11-21"
"index.md" "86c8fb559b13d1695d55b52dd6cbf574" "site/built/index.md" "2023-11-21"
"episodes/01-rstudio-intro.Rmd" "ba51e78f65d7c6c98be6b3329f5004ec" "site/built/01-rstudio-intro.md" "2023-11-21"
"episodes/02-project-intro.Rmd" "cd60cc3116d4f6be92f03f5cc51bcc3b" "site/built/02-project-intro.md" "2023-11-21"
"episodes/01-rstudio-intro.Rmd" "5e73c9f0c60d736ea458abe379ecef68" "site/built/01-rstudio-intro.md" "2023-11-21"
"episodes/02-project-intro.Rmd" "94e7911ebdd59fbc30de86ed1d84d4df" "site/built/02-project-intro.md" "2023-11-21"
"episodes/03-seeking-help.Rmd" "d24c310b8f36930e70379458f3c93461" "site/built/03-seeking-help.md" "2023-11-21"
"episodes/04-data-structures-part1.Rmd" "5ec938f71a9cec633cef9329d214c3a0" "site/built/04-data-structures-part1.md" "2023-11-21"
"episodes/05-data-structures-part2.Rmd" "de6c6ee224fa7201674d87844c9ede02" "site/built/05-data-structures-part2.md" "2023-11-21"
"episodes/06-data-subsetting.Rmd" "5d4ce8731ab37ddea81874d63ae1ce86" "site/built/06-data-subsetting.md" "2023-11-21"
"episodes/07-control-flow.Rmd" "6a8691c8668737e4202f49b52aeb8ac6" "site/built/07-control-flow.md" "2023-11-21"
"episodes/08-plot-ggplot2.Rmd" "a9a97a1eee46dc82b83c6c740a4412cf" "site/built/08-plot-ggplot2.md" "2023-11-21"
"episodes/08-plot-ggplot2.Rmd" "775bc2b258e11b4af447c7286bca2dd4" "site/built/08-plot-ggplot2.md" "2023-11-21"
"episodes/09-vectorization.Rmd" "e229eb061b3f072a132c4b31bbc2fdb0" "site/built/09-vectorization.md" "2023-11-21"
"episodes/10-functions.Rmd" "14edd4cf50edb8fefeb987a17d740e1a" "site/built/10-functions.md" "2023-11-21"
"episodes/11-writing-data.Rmd" "8b26e062dddd2394d00c6847ff0b7505" "site/built/11-writing-data.md" "2023-11-21"
"episodes/12-plyr.Rmd" "909597e71c188c682b5039036b4e95cf" "site/built/12-plyr.md" "2023-11-21"
"episodes/13-dplyr.Rmd" "182c5377ad81f0b25a19cd7a000e539e" "site/built/13-dplyr.md" "2023-11-21"
"episodes/14-tidyr.Rmd" "55773b26adb43d968e6e6d2b61627585" "site/built/14-tidyr.md" "2023-11-21"
"episodes/15-knitr-markdown.Rmd" "0c63ce92263a32f19fbec9f7b619b682" "site/built/15-knitr-markdown.md" "2023-11-21"
"episodes/13-dplyr.Rmd" "3ad3687a1c860ddcf30ddcbb375153fb" "site/built/13-dplyr.md" "2023-11-21"
"episodes/14-tidyr.Rmd" "6ceb2a517a291c565cfbc0f76e2fb567" "site/built/14-tidyr.md" "2023-11-21"
"episodes/15-knitr-markdown.Rmd" "65188e4a8eaf3d04c6284db65c48c83e" "site/built/15-knitr-markdown.md" "2023-11-21"
"episodes/16-wrap-up.Rmd" "c5ce0d34a37b7a99624ad1d6ac482256" "site/built/16-wrap-up.md" "2023-11-21"
"instructors/instructor-notes.md" "5ce85301c3e8d78b4b8682ae8e6bb7ff" "site/built/instructor-notes.md" "2023-11-21"
"instructors/instructor-notes.md" "b4c6bf83d3f7973f111ba4fa0da8cced" "site/built/instructor-notes.md" "2023-11-21"
"learners/discuss.md" "42ad66ab1907e030914dbb2a94376a47" "site/built/discuss.md" "2023-11-21"
"learners/reference.md" "9496509797663e42d7dc4050d45628bd" "site/built/reference.md" "2023-11-21"
"learners/reference.md" "b606f57847b81651e8102925ff3d19c1" "site/built/reference.md" "2023-11-21"
"learners/setup.md" "f888f8a54b071715c0cf56896e650c00" "site/built/setup.md" "2023-11-21"
"profiles/learner-profiles.md" "60b93493cf1da06dfd63255d73854461" "site/built/learner-profiles.md" "2023-11-21"
"renv/profiles/lesson-requirements/renv.lock" "b64d532ec943a5f118de48a81616ce98" "site/built/renv.lock" "2023-11-21"
"renv/profiles/lesson-requirements/renv.lock" "9ea97671cc72fef5529a03d0bf62d161" "site/built/renv.lock" "2023-11-21"
2 changes: 1 addition & 1 deletion reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ not expected by the programming language.

[type]{#type}
: The classification of something in a program (for example, the contents of a variable)
as a kind of number (e.g. [floating-point number](#floating-point-number), [integer](#integer)), [string](#string),
as a kind of number (e.g. [floating-point](#float), [integer](#integer)), [string](#string),
or something else. In R the command typeof() is used to query a variables type.

[while loop]{#while-loop}
Expand Down
Loading

0 comments on commit 1e23eca

Please sign in to comment.