You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This lesson uses mostly `combined.csv`. The 3 other csv files: `plots.csv`,
25
-
`species.csv` and `surveys.csv` are only needed for the lesson on databases.
26
-
27
-
`combined.csv` is downloaded directly in the episode "Starting with Data" and
28
-
does not need to be downloaded before hand. It however requires that there is a
29
-
decent internet connection in the room where the workshop is being taught. To
30
-
facilitate the download process, the chunk of code that includes the URL where
31
-
the csv file lives, and where the file should go and be named is included in the
32
-
code handout (see next paragraph). Using this approach ensures that the file
33
-
will be where the lesson expects it to be, and teaches good/reproducible
34
-
practice of automating the download. If the learners haven't created the `data/`
35
-
directory and/or are not in the correct working directory, the `download.file`
36
-
command will produce an error. Therefore, it is important to use the stickies at
37
-
this point.
22
+
<https://doi.org/10.6084/m9.figshare.1314459>
23
+
24
+
This lesson uses mostly `combined.csv`.
25
+
The 3 other csv files: `plots.csv`, `species.csv` and `surveys.csv` are only needed for the lesson on databases.
26
+
27
+
`combined.csv` is downloaded directly in the episode "Starting with Data" and does not need to be downloaded before hand.
28
+
It however requires that there is a decent internet connection in the room where the workshop is being taught.
29
+
To facilitate the download process, the chunk of code that includes the URL where the csv file lives, and where the file should go and be named is included in the code handout (see next paragraph).
30
+
Using this approach ensures that the file will be where the lesson expects it to be, and teaches good/reproducible practice of automating the download.
31
+
If the learners haven't created the `data/` directory and/or are not in the correct working directory, the `download.file` command will produce an error.
32
+
Therefore, it is important to use the stickies at this point.
38
33
39
34
## The handout
40
35
41
-
The [code handout](files/code-handout.R)
42
-
(a link to download it is also available on the top bar of the lesson website)
43
-
is useful for Data Carpentry workshops. It includes an outline of the lesson
44
-
content, the text for the challenges, the links for the files that need to be
45
-
downloaded for the lesson, and pieces of code that may be difficult to type for
46
-
learners with no programming experience/who are unfamiliar with R's syntax. We
47
-
encourage you to distribute it to the learners at the beginning of the
48
-
lesson. As an instructor, we encourage you to do the live coding directly in
49
-
this file, so the participants can follow along.
36
+
The [code handout](files/code-handout.R) (a link to download it is also available on the top bar of the lesson website) is useful for Data Carpentry workshops.
37
+
It includes an outline of the lesson content, the text for the challenges, the links for the files that need to be downloaded for the lesson, and pieces of code that may be difficult to type for learners with no programming experience/who are unfamiliar with R's syntax.
38
+
We encourage you to distribute it to the learners at the beginning of the lesson.
39
+
As an instructor, we encourage you to do the live coding directly in this file, so the participants can follow along.
50
40
51
41
## R Version
52
42
53
-
With the release of R 4.0.0 in early 2020, an important change has been made
54
-
to R: The default for `stringsAsFactors` is now `FALSE` instead of `TRUE`.
55
-
As a result, the `read.csv()` and `data.frame()` functions do not automatically
56
-
convert character columns to factors anymore (you can read more about it
57
-
[in this post on the R developer blog](https://developer.r-project.org/Blog/public/2020/02/16/stringsasfactors/index.html)).
43
+
With the release of R 4.
44
+
0\.
45
+
0 in early 2020, an important change has been made to R: The default for `stringsAsFactors` is now `FALSE` instead of `TRUE`.
46
+
As a result, the `read.csv()` and `data.frame()` functions do not automatically convert character columns to factors anymore (you can read more about it [in this post on the R developer blog](https://developer.r-project.org/Blog/public/2020/02/16/stringsasfactors/index.html)).
58
47
59
-
This change should not cause any problems with this lesson, independent of
60
-
whether R >4.0 is used or not, because it uses
61
-
`read_csv()` from the **`tidyverse`** package throughout. Other than
62
-
`read.csv()` from base R, `read_csv()` never converts character columns to
63
-
factors, regardless of the R version.
48
+
This change should not cause any problems with this lesson, independent of whether R >4.
49
+
0 is used or not, because it uses `read_csv()` from the **`tidyverse`** package throughout.
50
+
Other than `read.csv()` from base R, `read_csv()` never converts character columns to factors, regardless of the R version.
64
51
65
-
Nevertheless, it is recommended that learners install a version of R ≥4.0.0,
66
-
and instructors and helpers should be aware of this potential source of error.
52
+
Nevertheless, it is recommended that learners install a version of R ≥4.
53
+
0\.
54
+
0, and instructors and helpers should be aware of this potential source of error.
67
55
68
56
## RStudio and Multiple R Installs
69
57
70
-
Some learners may have previous R installations. On Mac, if a new install
71
-
is performed, the learner's system will create a symbolic link, pointing to the
72
-
new install as 'Current.' Sometimes this process does not occur, and, even
73
-
though a new R is installed and can be accessed via the R console, RStudio does
74
-
not find it. The net result of this is that the learner's RStudio will be
75
-
running an older R install. This will cause package installations to fail. This
76
-
can be fixed at the terminal. First, check for the appropriate R installation in
77
-
the library;
58
+
Some learners may have previous R installations.
59
+
On Mac, if a new install is performed, the learner's system will create a symbolic link, pointing to the new install as 'Current.
60
+
' Sometimes this process does not occur, and, even though a new R is installed and can be accessed via the R console, RStudio does not find it.
61
+
The net result of this is that the learner's RStudio will be running an older R install.
62
+
This will cause package installations to fail.
63
+
This can be fixed at the terminal.
64
+
First, check for the appropriate R installation in the library;
78
65
79
66
```
80
67
ls -l /Library/Frameworks/R.framework/Versions/
81
68
```
82
69
83
-
We are currently using R 4.0.x. If it isn't there, they will need to install it.
84
-
If it is present, you will need to set the symbolic link to Current to point to
85
-
the 4.0.x directory:
70
+
We are currently using R 4.
71
+
0\.
72
+
x.
73
+
If it isn't there, they will need to install it.
74
+
If it is present, you will need to set the symbolic link to Current to point to the 4.
If the problem occurs with `ggplot2` plots, an alternative workaround is to change the default theme for the R session, so that ggplot uses a *serif* font.
92
+
Since Arial is a *sans-serif* font, R will try to load a different font.
93
+
This can be done with `theme_update(text = element_text(family = "serif"))`.
104
94
105
95
## Required packages
106
96
107
-
Save yourself some aggrevation, and have everyone check and see if they can
108
-
install all these packages before you start the first day.
109
-
See the "Install required R packages" section on the homepage of the course
110
-
website for package installation instructions.
97
+
Save yourself some aggrevation, and have everyone check and see if they can install all these packages before you start the first day.
98
+
See the "Install required R packages" section on the homepage of the course website for package installation instructions.
111
99
112
100
Sometimes learners are unable to install the **`tidyverse`** package.
113
-
In that case, they can try to install the individual packages that are actually
114
-
needed:
101
+
In that case, they can try to install the individual packages that are actually needed:
@@ -214,44 +201,33 @@ The two main goals for this lessons are:
214
201
215
202
## Potential issues \& solutions
216
203
217
-
As it stands, the solutions to all the challenges are commented out in the Rmd
218
-
files. If you want to double check your answer, you can look at the source code
219
-
of the Rmd files on GitHub.
204
+
As it stands, the solutions to all the challenges are commented out in the Rmd files.
205
+
If you want to double check your answer, you can look at the source code of the Rmd files on GitHub.
220
206
221
207
## Technical Tips and Tricks
222
208
223
-
Show how to use the 'zoom' button to blow up graphs without constantly resizing
224
-
windows
209
+
Show how to use the 'zoom' button to blow up graphs without constantly resizing windows
225
210
226
211
Sometimes a package will not install, try a different CRAN mirror
227
212
228
213
- Tools > Global Options > Packages > CRAN Mirror
229
214
230
-
Alternatively you can go to CRAN and download the package and install from ZIP
231
-
file
215
+
Alternatively you can go to CRAN and download the package and install from ZIP file
232
216
233
217
- Tools > Install Packages > set to 'from Zip/TAR'
234
218
235
-
It is important that R, and the R packages be installed locally, not on a
236
-
network drive. If a learner is using a machine with multiple users where their
237
-
account is not based locally this can create a variety of issues (This often
238
-
happens on university computers). Hopefully the learner will realize these
239
-
issues before hand, but depending on the machine and how the IT folks that
240
-
service the computer have things set up, it may be very difficult to impossible
241
-
to make R work without their help.
219
+
It is important that R, and the R packages be installed locally, not on a network drive.
220
+
If a learner is using a machine with multiple users where their account is not based locally this can create a variety of issues (This often happens on university computers).
221
+
Hopefully the learner will realize these issues before hand, but depending on the machine and how the IT folks that service the computer have things set up, it may be very difficult to impossible to make R work without their help.
242
222
243
-
If learners are having issues with one package, they may have issues with
244
-
another. It is often easier to [make sure they have all the necessary packages installed](#required-packages)
245
-
at one time, rather then deal with these issues over and over.
223
+
If learners are having issues with one package, they may have issues with another.
224
+
It is often easier to [make sure they have all the necessary packages installed](#required-packages) at one time, rather then deal with these issues over and over.
246
225
247
-
In lesson 2 starting with data, one might not have the appropriate folder "data\_raw" in their working directory causing an error. This is a good time to go over reading an error, and a brief introduction of how to identify your working directory `getwd()` as well as setting your working directory `setwd("/somedirectory")` and if needed creating a directory within your script `dir.create("/some_new_directory")`, or simply creating it within a file explorer works if short on time.
226
+
In lesson 2 starting with data, one might not have the appropriate folder "data\_raw" in their working directory causing an error.
227
+
This is a good time to go over reading an error, and a brief introduction of how to identify your working directory `getwd()` as well as setting your working directory `setwd("/somedirectory")` and if needed creating a directory within your script `dir.create("/some_new_directory")`, or simply creating it within a file explorer works if short on time.
248
228
249
229
## Other Resources
250
230
251
-
If you encounter a problem during a workshop, feel free to contact the
252
-
maintainers by email or
253
-
[open an issue](https://github.com/fishtree-attempt/R-ecology-lesson/issues/new).
231
+
If you encounter a problem during a workshop, feel free to contact the maintainers by email or [open an issue](https://github.com/fishtree-attempt/R-ecology-lesson/issues/new).
254
232
255
-
For a more in-depth coverage of topics of the workshops, you may want to read
256
-
"[R for Data Science](https://r4ds.had.co.nz/)" by Hadley Wickham and Garrett
257
-
Grolemund.
233
+
For a more in-depth coverage of topics of the workshops, you may want to read " [R for Data Science](https://r4ds.had.co.nz/)" by Hadley Wickham and Garrett Grolemund.
There are some issues with these `ggplot2` examples. Can you figure out what is wrong with each one?
20
+
There are some issues with these `ggplot2` examples.
21
+
Can you figure out what is wrong with each one?
22
22
23
23
```{r, eval=FALSE}
24
24
ggplot(data = surveys,
25
25
mapping = aes(x = weight, y = hindfoot_length, color = "blue")) +
26
26
geom_point()
27
27
```
28
28
29
+
:::::::::::::::::::::::: solution
29
30
30
-
:::::::::::::::::::::::: solution
31
-
32
-
Our points don't actually turn out blue, because we defined the color inside of `aes()`. `aes()` is used for translating variables from the data into plot elements, like color. There is no variable in the data called "blue".
31
+
Our points don't actually turn out blue, because we defined the color inside of `aes()`.
32
+
`aes()` is used for translating variables from the data into plot elements, like color.
33
+
There is no variable in the data called "blue".
33
34
34
35
::::::::::::::::::::::::
35
36
@@ -39,7 +40,7 @@ ggplot(data = surveys,
39
40
geom_point()
40
41
```
41
42
42
-
:::::::::::::::::::::::: solution
43
+
:::::::::::::::::::::::: solution
43
44
44
45
Variable names inside `aes()` should not be wrapped in quotes.
45
46
@@ -51,7 +52,7 @@ ggplot(data = surveys,
51
52
+ geom_point()
52
53
```
53
54
54
-
:::::::::::::::::::::::: solution
55
+
:::::::::::::::::::::::: solution
55
56
56
57
When adding things like `geom_` or `scale_` functions to a `ggplot()`, you have to end a line with `+`, not begin a line with it.
57
58
@@ -62,7 +63,7 @@ ggplot(data = surveys, x = weight, y = hindfoot_length) +
62
63
geom_point()
63
64
```
64
65
65
-
:::::::::::::::::::::::: solution
66
+
:::::::::::::::::::::::: solution
66
67
67
68
When translating variables from the data, like `weight` and `hindfoot_length`, to elements of the plot, like `x` and `y`, you must put them inside `aes()`.
68
69
@@ -75,9 +76,10 @@ ggplot(data = surveys,
75
76
scale_color_continuous(type = "viridis")
76
77
```
77
78
78
-
:::::::::::::::::::::::: solution
79
+
:::::::::::::::::::::::: solution
79
80
80
-
`species_id` is a categorical variable, but `scale_color_continuous()` supplies a continuous color scale. `scale_color_discrete()` would give a discrete/categorical scale.
81
+
`species_id` is a categorical variable, but `scale_color_continuous()` supplies a continuous color scale.
82
+
`scale_color_discrete()` would give a discrete/categorical scale.
0 commit comments