-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rinstallation.qmd
55 lines (34 loc) · 2.83 KB
/
Rinstallation.qmd
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
# Installing R and RStudio
\
You will have to install R and RStudio separately. R
- The latest R version: [**R version 4.3.2 (31-10-2023)**](https://cran.rstudio.com/)
- As well as RStudio: [**RStudio Desktop**](https://posit.co/download/rstudio-desktop/)
In addition, we will need to install the following packages:
- `tidyverse`, `ggplot`, `faux`, `lme4`, `broom`, `broom.mixed`, `afex`, \`rmarkdown\`\`
- We can install packages with the following line of code:
```{r eval=FALSE, include=TRUE}
install.packages("tidyverse")
```
- To load packages, use the following line of code:
```{r eval=FALSE, include=TRUE}
library(tidyverse)
```
::: {.callout-warning appearance="simple"}
When installing packages, you will have to put the package's name into quotation marks (double or single). Otherwise, R will not be able to find and download the specific package. When loading a package, you do not have to put the name into quotation marks.
:::
::: {.callout-important appearance="simple"}
Apart from major R/ RStudio updates, you will not have to download the packages again before running your code. Once downloaded, the packages are saved to your computer. But you will have to load your packages when restarting R and running your code.
:::
## Working with R projects and R Markdown
RStudio projects provide a useful workflow for working with R. By using projects, you will have all of your files (e.g. data or scripts) accessible to your current R session. In short, R projects set the working directory.
::: {.callout-tip appearance="simple"}
When you start to analyse your data, create a new RProject as a first step. Making a RProject will automatically create a file with the .proj extension. Make sure to save this file together with all additional scripts in one folder. In addition, put your data into a subfolder titled "data". This subfolder is located in the same folder as your `.Rproj`-file and scripts.
:::
::: {.callout-caution appearance="simple"}
To initialise a new R-session, do so by opening the `.Rproj`-file and **not** by opening your R scripts. Doing so will ensure that your working directory is set up correctly.
:::
### RMarkdown
RMarkdown is a formatting language. It allows you to combine your code, results from your data analyses such as plots as well as written text chunks into a formatted and reproducible document. Its advantages lie in the reproducibility of your results since your code, your results from the analyses, your hypotheses, instructions, and even your conclusion can all be found in one document. In order to use RMarkdown, you will have to install the package `rmarkdown`.
Try to knit (= creating the document by executing the R code chunks and creating a R markdown (.md) document) the following two files:
- [file1](/downloadable_files/faux-stub.Rmd)
- [file2](/downloadable_files/mixed-stub.Rmd)