-
Notifications
You must be signed in to change notification settings - Fork 1
/
software.qmd
226 lines (151 loc) · 7.2 KB
/
software.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
---
eval: false
code-fold: false
engine: knitr
---
# Software
In this chapter we will guide you through the installation of R, RStudio and the packages you will need for this course.
**R** and **RStudio**[^software-1] are separate downloads.
[^software-1]: We will use RStudio, although if you already use other studio such as VScode, that's also fine.
## R
You will need **R** installed on your computer.
**R stats** (how it is also known) is a programming language and free software environment for statistical computing and graphics supported by the R Foundation for Statistical Computing.
The download links live at [The Comprehensive R Archive Network](https://cran.r-project.org/) (aka CRAN).
The most recent version is `4.4.1`, but you can use `>= 4.1.x` if you already have it installed.
:::: {.panel-tabset .nav-pills}
### Windows
[Download R-4.4.1 for Windows](https://cran.r-project.org/bin/windows/base/R-4.4.1-win.exe) and run the executable file.
::: {.callout-important icon="false"}
You will also need to install [Rtools](https://cran.r-project.org/bin/windows/Rtools/rtools44/rtools.html), which is a collection of tools necessary to build R packages in Windows.
:::
### Mac
[Download R-4.4.1 for MacOX](https://cran.r-project.org/).
You will have to choose between the arm64 or the x86-64 version.
Download the `.pkg` file and install it as usual.
### Ubuntu
> These are instructions for Ubuntu.
> If you use other linux distribution, please follow the instructions on [The Comprehensive R Archive Network - CRAN](https://cran.r-project.org/bin/linux/).
You can look for R in the Ubuntu **Software Center** or install it via the terminal:
```{bash}
# sudo apt update && sudo apt upgrade -y
sudo apt install r-base
```
**Or**, if you prefer, you can install the latest version of R from CRAN:
```{bash}
# update indices
sudo apt update -qq
# install two helper packages we need
sudo apt install --no-install-recommends software-properties-common dirmngr
# add the signing key (by Michael Rutter) for these repos
wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
# add the R 4.0 repo from CRAN -- adjust 'focal' to 'groovy' or 'bionic' as needed
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
```
Then run:
```{bash}
sudo apt install r-base r-base-core r-recommended r-base-dev
```
\[Optional\] To keep up-to-date r version and packages, you can follow the instructions at [r2u](https://eddelbuettel.github.io/r2u/)
::::
After this installation, you don't need to open R base.
Please proceed to install RStudio.
## RStudio
RStudio Desktop is an integrated development environment (IDE) for R.
It includes a console, syntax-highlighting editor that supports direct code execution, as well as tools for plotting, history, debugging and workspace management.
RStudio is available for free download from [Posit RStudio](https://posit.co/download/rstudio-desktop/).
::: {.panel-tabset .nav-pills}
### Windows 10/11
[Download RStudio 2024.04](https://download1.rstudio.org/electron/windows/RStudio-2024.04.2-764.exe) and run the executable file.
### MacOS
[Download RStudio 2024.04](https://download1.rstudio.org/electron/macos/RStudio-2024.04.2-764.dmg) and install it as usual.
### Ubuntu
> These are instructions for Ubuntu **22** / Debian 12.
> If you use other linux distribution, please follow the instructions on [Posit RStudio](https://posit.co/download/rstudio-desktop/).
Install it via the terminal:
```{bash}
sudo apt install libssl-dev libclang-dev
wget https://download1.rstudio.org/electron/jammy/amd64/rstudio-2024.04.2-764-amd64.deb
sudo dpkg -i rstudio*
rm -v rstudio*
```
If you already use Ubuntu **24**, please check and replace the correct url from [RStudio Dailies](https://dailies.rstudio.com/)
```{bash}
#| echo: false
sudo apt install libcurl4-openssl-dev libgit2-dev libfontconfig1-dev libxml2-dev libharfbuzz-dev libfribidi-dev libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev
sudo apt install libudunits2-dev libgdal-dev libgeos-dev
```
:::
## R packages
You will need to install some packages to work with the data and scripts in this course.
You can install them in RStudio by searching for them in the **Packages** tab:
![](images/clipboard-3443685728.png)
**or** by running the following code in the console:
```{r}
install.packages("tidyverse")
install.packages("readxl")
install.packages("sf")
install.packages("mapview")
install.packages("rmarkdown")
install.packages("centr")
install.packages("od")
install.packages(c("remotes", "devtools", "usethis")) # optional
install.packages("osmextract") # optional
install.packages("stplanr") # optional
```
## r5r
The workshop **“A crash course on urban accessibility with R"** uses a few R packages that need to be installed on your machine. The simplest way to do this is running the code below. This might take a few minutes if this is the first time you install these packages.
```{r}
pkgs = c("r5r", "accessibility", "rJavaEnv", "h3jsr", "quantreg")
install.packages(pkgs)
```
### Java Development Kit
To use the `{r5r}` package (version v2.0 or higher), you will need to have *Java Development Kit (JDK) 21* installed on your computer.
There are numerous open-source JDK implementations.
The easiest way to install JDK is using the new [{rJavaEnv}](https://www.ekotov.pro/rJavaEnv/) package in R.
```{r}
# check version of Java currently installed (if any)
rJavaEnv::java_check_version_rjava()
## if this is the first time you use {rJavaEnv}, you might need to run this code
## below to consent the installation of Java.
# rJavaEnv::rje_consent(provided = TRUE)
# install Java 21
rJavaEnv::java_quick_install(
version = 21,
distribution = 'Corretto')
# check if Java was successfully installed
rJavaEnv::java_check_version_rjava()
```
**Alternatively**, you can manually download and install JDK 21.
::: {.panel-tabset .nav-pills}
### Windows and MacOS
Go to [Java Development Kit 21](https://jdk.java.net/archive/), download the latest 21 build corresponding to your operating system and run the executable file.
### Ubuntu
Install it via the terminal:
```{bash}
sudo apt install -y openjdk-21-jdk openjdk-21-jre
java -version
```
:::
## tinytex
To be able to **export** your Rmakdown document to a pdf file, you will need a LaTeX processor.
`tinytex` is a low weight R package with the most used features of LaTeX that you can use with R.
```{r}
# you need to run both lines
install.packages("tinytex")
tinytex::install_tinytex()
```
To use some LaTeX packages, you also need to install `tlmgr`.
```{r}
tinytex::tlmgr_install()
tinytex::tlmgr_update() # updates all latex pkgs
```
<!-- ## Open Route Service -->
<!-- [Sign up for an account](https://openrouteservice.org/dev/#/signup) and create a token. -->
<!-- Copy your API. -->
<!-- In RStudio console, run: -->
<!-- ```{r} -->
<!-- # install.packages("openrouteservice") -->
<!-- openrouteservice::ors_api_key("YOUR-API-KEY") -->
<!-- ``` -->
<!-- This will store your key on your `.Renviron` file, meaning that every time you open RStudio, you won't need to run this command again. -->
<!-- This is useful also to write your `openrouteservice` scripts without sharing your key with others. -->