-
Notifications
You must be signed in to change notification settings - Fork 2
/
03-installation-and-troubleshooting.Rmd
152 lines (109 loc) · 6.57 KB
/
03-installation-and-troubleshooting.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
148
149
150
151
152
# Installation & Troubleshooting
The workshop *R for Humanities* makes use of R and Rstudio.
Also, R packages bundled in the `tidyverse` are used.
This document shows how to install R and RStudio, and how to install and load tidyverse from Rstudio.
Most workshops on R programming make use of an RStudio server.
With an RStudio server, the participant logs in onto the website and gets a web based RStudio IDE.
We prefer a local installation of RStudio for our workshop.
We hope that this removes a barrier for users to start working with R themselves.
Because not every system is equally cooperative in installing everything, we have compiled an elaborate.
Please let us know of any errors that you encountered, and how you fixed them!
We will add these to the guide.
## Installation
### Install R and RStudio on a personal laptop.
I.e. a laptop *with* administrator rights.
1. Install R from https://cran.rstudio.com/
2. Install Rstudio from https://www.rstudio.com/products/rstudio/download/#download
### Install R and RStudio on a Utrecht University laptop.
1. Open **Software Center**
2. Install **R for Windows**
Installing R packages on a Utrecht University laptop can be hard. This is because R packages are installed on a so-called 'mounted' drive. This causes problems with the performance. Check the installation as follows:
3. Open **RStudio**
4. Write the following line of code in your console: `.libPaths()`, and press enter to execute.
5. If the response starts with `//` or `\\`, you are installing on a mounted drive. Follow the steps on the next page to change the installation location.
### Install Tidyverse from Rstudio
From the console:
1. Open Rstudio.
2. Look for a window that says "console" (probably bottom left of your screen).
3. In the console, type: `install.packages("tidyverse")`
4. hit 'enter'.
You can also install using the RStudio GUI:
1. Open Rstudio.
2. At the window on the bottom right of your screen, select the tab "packages".
3. Click "install" and type "tidyverse" in the box.
4. Make sure the checkbox marked "install dependencies" is checked, and click "install".
The tidyverse installation might take a while, just let it run. If it asks you something, say 'yes', unless it looks particularly outlandish.
If you want to check your tidyverse installation, find the 'console' window, and type:
`library(tidyverse)`. Then hit 'enter'.
You should see something that looks like this:
```{r eval=FALSE}
── Attaching packages ────────────────────────────────────────────────tidyverse 1.2.1 ──
✔ ggplot2 2.2.1 ✔ purrr 0.2.5
✔ tibble 1.4.2 ✔ dplyr 0.7.4
✔ tidyr 0.8.1 ✔ stringr 1.2.0
✔ readr 1.1.1 ✔ forcats 0.3.0
── Conflicts ────────────────────────────────────────────────tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
```
## Troubleshooting
### Packages are being installed on a mounted drive
This can cause various errors, and even if everything goes right, installing tidyverse takes ages.
Solution 1:
- There is a solution to prevent problems with mounted drives for applications like R, RStudio and Office. Read more about the solution on intranet. https://intranet.uu.nl/en/current-affairs/announcements/would-you-make-your-solis-laptop-work-more-efficiently
Solution 2:
- Create a folder `R-packages` on a local drive.
- Copy the location to that drive. For example: `C:/Users/User/R-packages`.
- Run the following line of code: `file.edit(file.path("~", ".Rprofile"))`
- Paste `.libPaths("C:/Users/User/R-packages")` in the editor and save the file.
- Restart your R session
- Click on `Packages`>`Install`. Is `Install to library` pointing to `C:/Users/User/R-packages`?
- If not: check if the path is correctly spelled. Try inverting the slashes (`\` instead of `/`). You may need to use double slashes (`\\` or `//`).
- Tick 'source on save', click save, and check `Packages`>`Install` again.
### Tidyverse installation is aborted
If the installation of tidyverse is aborted, and packages are downloaded but their installation is said to have `non zero exit status`, you may be dealing with an old version of R.
Update R by installing a recent version from [CRAN](https://cran.rstudio.com/).
Then try installing tidyverse again.
Do you have Rtools installed?
(Only on Windows; it is not clear why this works but it sometimes does.)
Install this via [cran.r-project.org/bin/windows/Rtools/](https://cran.r-project.org/bin/windows/Rtools/).
### "Unable to move temporary installation" (Windows error)
Do you get issues like this:
```{r eval=FALSE}
> install.packages("tibble")
Installing package into ‘C:/Users/UserName/R’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/tibble_1.4.2.zip'
Content type 'application/zip' length 172649 bytes (168 KB)
downloaded 168 KB
package ‘tibble’ successfully unpacked and MD5 sums checked
Warning in install.packages :
unable to move temporary installation ‘C:\Users\UserName\R\file18b813387562\tibble’ to ‘C:\Users\UserName\R\tibble’
The downloaded binary packages are in
C:\Users\UserName\AppData\Local\Temp\RtmpYh5ogU\downloaded_packages
```
Check for the line **unable to move temporary installation**. Your virus scanner might be blocking the installation of tidyverse.
The solution ([found here](https://code.adonline.id.au/unable-to-move-temporary-installation-r/)) is to enter:
```{r eval=FALSE}
trace(utils:::unpackPkgZip, edit=TRUE)
```
You should see:
```{r eval=FALSE}
Tracing function "unpackPkgZip" in package "utils (not-exported)"
[1] "unpackPkgZip"
```
And a file should open.
Change 0.5 in line 142 to 2.5, save the file, and try installing tidyverse again.
### Library(tidyverse) loading failed
Dependencies might be missing, or outdated, and need to be installed/updated manually.
For instance, you see the following error:
```{r eval=FALSE}
Error: package or namespace load failed for 'tidyverse'in loadNamespace(...)
namespace 'bindrcpp' 0.2 is being loaded, but >= 0.2.0.9000 is required.
```
Run `install.packages("bindrcpp")`to update this package.
```{r eval=FALSE}
Error: package or namespace load failed for 'tidyverse'in loadNamespace(...)
there is no package called (xxx)
```
The same solution as above applies: run `install.packages()` to add whatever package is missing. (At the time of writing, it is not clear why these packages are missing; this error was received over email.)