- "markdown": "# Preparation Course {#w0-preparation}\n\nIn this course we will be using R, RStudio and Git. We ask you to install and/or update these programs *before* the start of the course, so that we do not loose time once the course starts. In this chapter, we cover the course requirements and some tips on how you should change your RStudio settings. \n\n\n\n\n\n\n\n\n\n## Install or update R (not RStudio)\n\nIf you haven't installed R yet, do so now by getting the newest version from [CRAN](https://cran.r-project.org/). If you do have R installed, check your Version of `R` by opening RStudio and typing the following command into the console. \n\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\nR.version.string\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\n[1] \"R version 4.3.3 (2024-02-29)\"\n```\n\n\n:::\n:::\n\n\n\n\nThis returns the version number of your R installation, whereas the first digit (`4`) indicates the number of the *major release*, the second digit (`3`) indicates the *minor release* and the last digit (`3`) refers to the *patch release*. As a general rule of thumb, you will want to update R if you\n\n- don't have the current *major* version or\n- are lagging two (or more) versions behind the current *minor release*\n\nIn the time of writing (February, 2025), the current `R` Version is 4.4.2 (released on 31.10.2024, see [cran.r-project.org](https://cran.r-project.org/)). Your installation should therefore not be older than 4.3.0.\n\nIf your current installation is older, make sure that you have updated R before the course. Check [these instructions on how to update R](https://www.linkedin.com/pulse/3-methods-update-r-rstudio-windows-mac-woratana-ngarmtrakulchol/)\n\n## Install or update RStudio {#sec-update-rstudio}\n\nRStudio is the IDE (integrated development environment) we use in our course to interact with R. There are good alternatives you can use, RStudio simply seems to be [the most popular choice](https://twitter.com/mdancho84/status/1502237075550392323). If you want to use your own IDE, please feel free to do so. However, we don't recommend this if you are a beginner.\n\nWe recommend updating RStudio to the newest version before the course: check if this is the case by clicking on *help > check for updates*. \n\n## Install the necessary packages\n\nIn the course, we will be needing several packages. Save time during the course by installing these upfront! The classical way to install a package (e.g. `pacman`) is as follows:\n\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\ninstall.packages(\"pacman\")\n```\n:::\n\n\n\n\nHowever, the function `install.packages` does not check whether you already have the package installed. If you only want to install missing packages, you can use the function `p_install` with the option `force = FALSE` (from the package `pacman`).\n\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\nlibrary(\"pacman\")\n\np_install(\"dplyr\", force = FALSE)\np_install(\"ggplot2\", force = FALSE)\np_install(\"readr\", force = FALSE)\np_install(\"tidyr\", force = FALSE)\np_install(\"sf\", force = FALSE)\np_install(\"terra\", force = FALSE)\np_install(\"tmap\", force = FALSE)\np_install(\"zoo\", force = FALSE)\np_install(\"units\", force = FALSE)\np_install(\"plotly\", force = FALSE)\np_install(\"patchwork\", force = FALSE)\n```\n:::\n\n\n\n\n\n## Configure RStudio{#configure-rstudio}\n\nNow we will set some RStudio Global options. Go to *Tools → Global options*. \n\n- **R General**\n - Deactivate the option \"*Restore .RData into workspace at startup*\"[^restore]\n - Set \"*Save workspace to .RData on exit*\" to \"*Never*\"[^saveworkspace]\n- **Code**\n - Activate the option \"*Use native pipe operator, |> (requires R 4.1+)*\"[^pipe]\n- **R Markdown**\n - Deactivate the option \"*Show output inline for all R Markdown documents*\"\n\n\n \nClick on \"Ok\" to apply the change and close the options menu.\n\n[^restore]: We recommend that you start each RStudio session with a blank slate, as recommended by @wickham2023 see [here](https://r4ds.hadley.nz/workflow-scripts#projects)\n[^saveworkspace]: If we don't restore the workspace at startup, there is no need to save it on exit.\n[^pipe]: Our group has adapted the native pipe operator `|>` to reduce package dependencies. If you use the `magrittr` pipe `%>%` and would like to stick to it, feel free. \n",
0 commit comments