-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstalling-r.qmd
151 lines (95 loc) · 8.43 KB
/
installing-r.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
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
148
149
150
---
title: Installing and Configuring R and RStudio
pagetitle: Installing R
author:
- Biometry Hub, University of Adelaide
date: today
date-format: "MMMM YYYY"
toc: true
format:
pdf:
pdf-engine: pdflatex
html:
highlight: textmate
linkcolor: blue
urlcolor: blue
params:
rlatest: "4.3.1"
---
---
# Introduction
**Welcome!**
This guide provides a brief introduction and a step-by-step guide on the installation of all software requirements for the Biometry Hub workshops including R, Rstudio and required packages. It may also be useful for other situations such as an internship or student project with the Biometry Hub. You can find a PDF copy of this guide here: <https://biometryhub.github.io/installing-r/installing-r.pdf>
We will be using the R environment for statistical computing and graphics, so we need to install the following:
- The language platform - [R](#R)
- An integrated development environment (IDE) - [RStudio](#RStudio), which serves as the front end, or interface, for R.
- Additional packages (if required).
Installation of additional packages will be required for later courses (e.g. `biometryassist` and `ASReml-R`), but for the first course _Introduction to R_, R and RStudio are enough.
This guide assumes you are running a relatively recent version of Microsoft Windows, for example Windows 8 or later, or Mac OS X/macOS 10.11 (El Capitan) or later.
R and RStudio are available for some of the most common Linux distributions (`DEB` and `RPM` packages available), and there is no problem using Linux for the courses, but unfortunately these installation instructions do not cover installation on Linux. There are several guides available on the internet, so if you have problems we suggest this is a good starting point.
# Installation
<!-- ## Environment Variables (Windows Only) {#EVs .tabset} -->
<!-- Those using University of Adelaide computers with Microsoft Windows should first set up Environment variables in Windows. For other Windows users this step is optional, but **recommended**. -->
<!-- The default way R is installed can cause some issues for Windows computers, especially University owned computers. Using environment variables forces R to install packages to a location which can prevent issues. If you have trouble with this step, you may need to contact your IT administrators for their assistance. -->
<!-- ### Windows -->
<!-- 1. Create the following folder structure: "C:\\R\\Library" -->
<!-- 1. Click the start button or press the Windows key on your keyboard, then type in "Edit Environment". -->
<!-- ![Start search](Images/Installing_R/Start_Search.PNG) -->
<!-- 1. Click the "Edit environmental variables for your account" option (should be first option). -->
<!-- 1. Click `New` in the middle of the new window under the User variables section. -->
<!-- ![Environment Variable](Images/Installing_R/Environment_Variable.PNG) -->
<!-- 1. Enter `R_LIBS_USER` for the variable name and "C:\\R\\Library" for the value. -->
<!-- 1. Click Ok and close the window. -->
<!-- ### Mac: Hide this section -->
## R {#R}
R is a language and platform for statistics, computing and graphics, that is freely available. Among the functions in R are facilities to handle data, integrated tools for data analysis, graphics facilities for data analysis and a simple, well developed programming language. For more information please visit the R project homepage listed in [Further resources](#Further).
### Windows
1. Go to <https://cran.rstudio.com/bin/windows/base/release.htm> to download the most recent version of R onto your computer.
2. Run the downloaded file by opening the folder where you downloaded the file and double clicking on the filename (e.g. `r paste0("R-", params$rlatest, ".exe")`).
3. Installation to `C:/Program Files` is recommended, which may require administrative privileges.
3. Follow the prompts in the installation. For our purposes, the installation defaults are satisfactory, so you can simply click on `Next` through the installation until it is complete.
### Mac
1. Go to <https://cran.rstudio.com/bin/macosx/> and download the most recent version of R for your version of macOS onto your computer.
i) macOS 11 (Big Sur) and later (Apple M1 Chips or later): At the time of writing [R `r params$rlatest`](`r paste0("https://cran.r-project.org/bin/macosx/big-sur-arm64/base/R-", params$rlatest, "-arm64.pkg")`) was the latest version.
i) macOS 11 (Big Sur) and later (Intel 64bit): At the time of writing [R `r params$rlatest`](`r paste0("https://cran.rstudio.com/bin/macosx/big-sur-x86_64/base/R-", params$rlatest, "-x86_64.pkg")`) was the latest version.
i) macOS 10.13 (High Sierra) and later (Intel 64bit): At the time of writing [R 4.2.3](https://cran.rstudio.com/bin/macosx/base/R-4.2.3.pkg) was the latest version.
## RStudio {#RStudio}
RStudio is a powerful interactive development environment (IDE) for R which adds tools to make working with R easier. It is the recommended environment for all Biometry Hub training courses. In this section we describe the setup of RStudio.
### Windows
1. Download the latest version from <https://posit.co/download/rstudio-desktop/#download>.
2. Run the downloaded file by opening the folder where you downloaded the file and double clicking on the filename.
3. Installation to `C:/Program Files` is recommended, which may require administrative privileges.
3. As with the R installation, the installation defaults are fine.
### Mac
1. Download the latest version from <http://rstudio.org/download/latest/stable/desktop/mac/RStudio-latest.dmg>.
2. Run the downloaded file by opening the folder where you downloaded the file and double clicking on the filename.
3. As with the R installation, the installation defaults are fine.
## Check {#Check}
Check that R and RStudio have installed correctly by opening RStudio. By default, RStudio usually doesn't install an icon on your desktop, so search in the Start Menu (Windows) or Spotlight (Mac) for "RStudio". The icon you want looks something like this: ![RStudio Desktop Shortcut](Images/Installing_R/Desktop_Shortcut.PNG)
You don't need to click on the R icon, or run the program R, as RStudio will do this automatically for you.
RStudio should start up and look something like this:
![RStudio main window on Windows](Images/Installing_R/R_Studio_blank.png)
## Packages
These will be discussed further in the workshop, however to maximise learning time, please follow the following steps to install these before the workshop. The steps are identical for all operating systems.
Once RStudio is open (see [Check](#Check) above), just copy and paste the following command next to the `>` arrow in the console window on the left hand side of the session (see image below for placement), and then press enter.
```{r, eval=FALSE}
source("https://link.biometryhubwaite.com/installpackages"); required_packages()
```
<br>
![RStudio package installation](Images/Installing_R/R_studio_installing_packages.png)
<br>
**Note:** This may take some time (5-10 minutes or more) depending on your internet speed and computer hardware. You will notice some red text appears in Rstudio, eventually followed by black text. This is normal and no cause for concern. You needn't read or record any of the text. Here is an image of what this step will look like:
![RStudio package installation](Images/Installing_R/R_studio_packages.png)
If this completes successfully, you will see "All required packages have been installed." probably in red text. If there is an error, the installation will provide some instructions.
# Done!
Congratulations! If you have made it this far, you are now set up and ready for the workshop.
If you have experienced issues or errors and the software has not installed correctly, please [contact us early via email](mailto:[email protected]). Alternatively, you can arrive 15 minutes early for the workshop to allow time to get the software installed and ready.
---
# Further resources {#Further}
The above will get your basic setup ready but here are some links if you are interested in reading a bit further.
- R project homepage: <https://www.r-project.org/>
- RStudio homepage: <https://posit.co/products/open-source/rstudio/>
- How to Use RStudio: <https://support.posit.co/hc/en-us/categories/200035113-Documentation>
- R Installation and Administration: <https://cran.r-project.org/doc/manuals/R-admin.html>
- R FAQ: <https://cran.r-project.org/doc/FAQ/R-FAQ.html>