-
Notifications
You must be signed in to change notification settings - Fork 10
/
home_precourse.Rmd
147 lines (93 loc) · 6.59 KB
/
home_precourse.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
---
title: "Precourse"
output:
bookdown::html_document2:
highlight: textmate
toc: false
toc_float:
collapsed: true
smooth_scroll: true
print: false
toc_depth: 4
number_sections: false
df_print: default
code_folding: none
self_contained: false
keep_md: false
encoding: 'UTF-8'
css: "assets/lab.css"
include:
after_body: assets/footer-lab.html
---
```{r,child="assets/header-lab.Rmd"}
```
This workshop is aimed towards biologists, and other life sciences researchers with none or limited experience with R programming or even programming in general.
# {.tabset .tabset-fade}
## Preparation
### Tools
`r fa1("chevron-circle-right")` **Install R statistical software**
<div class="boxy boxy-exclamation boxy-yellow">
If you have an old version of R and you do not use it, uninstall it and then install a newer version. If you prefer to keep your old R version, then you can still install a newer version for this workshop. This is easy on Windows, but can be tricky on Linux.
</div>
Go to [r-project.org](https://cloud.r-project.org/) and choose the link appropriate for your operating system.
<img src="data/common/r-download.png" class="fancyimage">
<div class="boxy boxy-lightbulb">
**Installation details**
<i class="fab fa-windows"></i> **Windows:** Click **Download R for Windows** > **base** > **Download R X.X.X for Windows**. This should download an .exe file. It is recommended that you DO NOT install to `C:\Program Files\R\`. Instead, install to `C:\R\`. It is also recommended that you install Rtools for building R packages from source code. Click **Download R for Windows** > **Rtools**.
<i class="fab fa-apple"></i> **Mac:** Click **Download R for (Mac) OS X** > **R-X.X.X.pkg** that will download R to your computer. If you are not sure what version of Mac OS you are running, click the apple on the top left of your screen and select **About this mac** (Om den här datorn). In case you are running something older than 10.9, you should instead pick the “R-X.X.X-snowleopard.pkg” to install. Note that this will not give you the latest version of R, but it will be sufficient for most sections of the course. You can then double-click the downloaded package that will prompt you with some questions for installation details. Stick with the default settings and you should be fine.
<i class="fab fa-linux"></i> **Linux:** Click **Download R for Linux** then pick your distribution of Linux. On most distributions, this will be via a software install system like `yum` or `apt-get`. If you run this make sure that you update your information to the installer first, otherwise you might end up installing at outdated version of R. For some systems you might need to install not only **r-base**, but also **r-devel** or you will lack important features of your R installation. When installing R packages, you might need to install OS specific packages before. These are displayed during R package installation.
</div>
`r fa1("chevron-circle-right")` **Install [RStudio](https://rstudio.com/products/rstudio/download/#download)**. Choose based on your OS.
[![](data/common/rstudio.png)](https://rstudio.com/products/rstudio/download/#download)
RStudio provides you with tools like code editor with highlighting, project management, version control, package building, debugger, profiler and more. Start up RStudio to check that everything has been installed correctly. If not, contact us and we can help you out.
You can also watch [this video](https://youtu.be/suX6nsSUXDw?si=FbaiaCpRNvtjxt5N) for an introduction to using RStudio
`r fa1("chevron-circle-right")` **Install R packages**
Please download this [test_installation.Rmd file](data/common/test_installation.Rmd) and Knit/Render it by clicking on the knit/render icon on the upper right of R Studio or by navigating to file > knit document.
After rendering if everything goes well you should see this message towards end of the rendered html file:
- **Congratulations you have installed all the packages**.
If there are any missing packages they will be printed at the end of the rendered html file.
<video width="640" height="480" controls>
<source src="data/common/Test_Installation.mov" type="video/mp4">
Your browser does not support the video tag.
</video>
<!-- Extra R packages used in the workshop exercises (if any) are listed below. It is recommended that you install this in advance. Simply copy and paste the code into R. -->
```{r , echo = F, eval = F}
# this first chunk runs through the root directory, finds the installed packages across the files and prints them as installation instruction.
#Add to the pkg_discard object the packages you want to discard from the list
pkg<-unique(renv::dependencies()$Package)
pkg_discard<-c("mkteachr", "manipulateWidget", "emo")
pkg_list<-pkg[!pkg %in% pkg_discard]
```
```{r echo=FALSE, warning=FALSE, chunk.title=NULL, class.output="r", comment="", r,eval=FALSE}
cat("# install from cran\n")
cat(paste0("install.packages(c('",paste(pkg_list,sep="",collapse="','"),"'))"))
cat("\n")
```
`r fa1("chevron-circle-right")` **Install Docker**
It is NOT absolutely necessary to have Docker installed, but we are working on shipping the working course as a Docker container ready to run. In order to be able to use this functionality, please make sure you have [Docker Desktop](https://www.docker.com/get-started) installed and running on your machine.
`r fa1("chevron-circle-right")` **Install git**
In order to use RStudio's version control features, install [Git](https://git-scm.com/downloads) on your machine. This step is also NOT necessary, but to our experience learning and using git makes your life much easier.
`r fa1("chevron-circle-right")` **Install Zoom**
Go to [Zoom website](https://zoom.us) and follow installation instructions. Most likely, your University has already paid some pro plan and you should consult your local IT to get university account details.
***
## Syllabus
The syllabus for this workshop are as follows.
* General introduction to programming and R.
* R environment and RStudio IDE.
* Data types.
* Variables and operators.
* Input/Output.
* Control structures.
* Functions and variable scope.
* Base and ggplot2 graphics.
* Overview of R package anatomy.
* Brief introduction to Tidyverse.
* Brief introduction to RMarkdown.
***
## Learning outcomes
* Feeling comfortable while working with R in RStudio.
* Being able to read some data and perform basic data manipulation in R.
* Being able to perform some basic analysis and generate plots in R.
* Being able to generate a simple report.
***
#