-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstall_R.Rmd
More file actions
92 lines (63 loc) · 5.89 KB
/
Copy pathInstall_R.Rmd
File metadata and controls
92 lines (63 loc) · 5.89 KB
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
---
title: "Installing R, RStudio and packages"
author: Linda T. Betz, M.Sc.
date: January 11, 2021
output:
beamer_presentation:
theme: "Boadilla"
colortheme: "seahorse"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
def.chunk.hook <- knitr::knit_hooks$get("chunk")
knitr::knit_hooks$set(chunk = function(x, options) {
x <- def.chunk.hook(x, options)
ifelse(options$size != "normalsize", paste0("\n \\", options$size,"\n\n", x, "\n\n \\normalsize"), x)
})
```
# Installing R, RStudio and packages
In the tutorial, we will work with R, a free, open source programming language for data analytics, statistics and visualization. Please make sure to install the latest version of **R and RStudio** prior to the first tutorial session on January 18. This typically takes less than half an hour. Install R first, and *then* RStudio. Lastly, we will ask you to install some packages in advance.
\
\
\
{ width=33% height=33% }
# How to download and install R
R is maintained by a team of developers who make the language available for free through the web page of *The Comprehensive R Archive Network* (http://cran.r-project.org/). The top of the web page provides three links for downloading R. Follow the link that describes your operating system: Windows, Mac OS, or Linux. We recommend to install R in English.
# Windows
To install R on Windows, click the “Download R for Windows” link. Then click the “base” link. Next, click the first link at the top of the new page. This link should say something like “Download R 4.0.3 for Windows”. The link downloads an installer program, which installs the most up-to-date version of R for Windows. Run this program and step through the installation wizard that appears. The installer lets you customize your installation, but the defaults will be suitable for most users. The wizard will install R into your program files folders and place a shortcut in your Start menu. Note that you’ll need to have all of the appropriate administration privileges to install new software on your machine.
# Mac OS
To install R on a Mac, click the “Download R for Mac” link. Next, click on the R-4.0.3 package link (or the package link for the most current release of R). An installer will download to guide you through the installation process, which is very easy. The installer lets you customize your installation, but the defaults will be suitable for most users. If your computer requires a password before installing new progams, you’ll need it here.
# Linux
R comes preinstalled on many Linux systems, but you need the newest version of R for the tutorial if yours is out of date. The CRAN website provides files to build R from source on Debian, Redhat, SUSE, and Ubuntu systems under the link “Download R for Linux.” Click the link and then follow the directory trail to the version of Linux you wish to install on. The exact installation procedure will vary depending on the Linux system you use. CRAN guides the process by grouping each set of source files with documentation or README files that explain how to install on your system. You can customize your installation, but the defaults will be suitable for most users.
# How to download and install RStudio
RStudio is an IDE that makes writing and organizing your R code a lot easier. The RStudio interface looks the same for Windows, Mac OS, and Linux.
You can download RStudio for free (https://rstudio.com/products/rstudio/download/#download). Install RStudio Desktop by selecting the correct installer depending on your operating system (the website will make a recommendation that will usually work) and follow the simple steps provided. Once you’ve installed RStudio, you can open it like any other program on your computer—usually by clicking an icon on your desktop.
# Opening RStudio
After both installations, please launch RStudio. If you were successful with the installations, you should see a window similar to this (note that the R version reported on your screen will be different):
{ width=80% height=80% }
# How to install packages
Many useful functions do not come preloaded when you start R, but reside in packages to be installed on top of R. For the tutorial, please install some packages in advance ("tidyverse", "caret", "e1071", "mlr"). To do that, open RStudio and type
```{r, eval=FALSE}
install.packages(c("tidyverse", "caret", "e1071", "mlr"))
```
at the command prompt (`>`) of the console and press enter to execute the code. In case you're asked whether you would also like to install dependencies, choose "yes". A number of messages will scroll by, and there will be a 1-2 minute pause where nothing appears to happen (but the installation is actually occurring). At last, the output parade should end with a message like:
`The downloaded source/binary packages are in....`
Note that you need a connection to the internet to install packages.
# Test if the installation worked
Test if installation worked by typing in the console: `library(tidyverse)`.
If everything worked fine, the output in the console should look similar to this:
```{r, size="tiny"}
library(tidyverse)
```
# Test if the installation worked
Similarly, for the other packages:
```{r, size="tiny"}
library(caret)
library(e1071)
library(mlr)
```
# Problems
If something did not work (e.g., you get an error message of the nature `Error in library(tidyverse) : there is no package called ‘tidyverse’`), try to install the packages manually by clicking Tools → Install packages in RStudio. For other error messages, you may go ahead and google them to try to solve the problem on your own. Warning messages can be ignored for now.
\
\
If you cannot get things running after consulting Google, please contact us a few days **before the tutorial** (linda.betz@uk-koeln.de) :). Once the tutorial starts, we will not be able to give you one-to-one assistance with troubleshooting installation problems.