Skip to content

Commit 7823cf9

Browse files
committed
updated and simplified installation instructions, and moved the moving files from JupyterHub to an appendix
1 parent 079688c commit 7823cf9

File tree

3 files changed

+97
-56
lines changed

3 files changed

+97
-56
lines changed

_bookdown.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ language:
33
ui:
44
chapter_name: "Chapter "
55
delete_merged_file: true
6-
rmd_files: ["index.Rmd", "intro.Rmd", "reading.Rmd", "wrangling.Rmd", "viz.Rmd", "classification1.Rmd", "classification2.Rmd", "regression1.Rmd", "regression2.Rmd", "clustering.Rmd", "inference.Rmd", "jupyter.Rmd", "version-control.Rmd", "setup.Rmd", "references.Rmd"]
6+
rmd_files: ["index.Rmd", "intro.Rmd", "reading.Rmd", "wrangling.Rmd", "viz.Rmd", "classification1.Rmd", "classification2.Rmd", "regression1.Rmd", "regression2.Rmd", "clustering.Rmd", "inference.Rmd", "jupyter.Rmd", "version-control.Rmd", "setup.Rmd", "references.Rmd", "appendixA.Rmd"]

appendixA.Rmd

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
\cleardoublepage
2+
3+
```{r echo=FALSE, results='asis'}
4+
if(!knitr::is_latex_output()){
5+
cat("# (APPENDIX) Appendix {-}")
6+
} else {
7+
cat("\\appendix")
8+
}
9+
```
10+
11+
# Download files from a JupyterHub for later local use {#appendixA}
12+
13+
This section will help you
14+
save your work from the JupyterHub web-based platform to your own computer.
15+
16+
First, in JupyterHub, open a terminal by clicking "terminal" in the Launcher tab.
17+
Next, type the following in the terminal to create a
18+
compressed `.zip` archive for the work you are interested in downloading:
19+
20+
```
21+
zip -r hub_folder.zip your_folder
22+
```
23+
24+
After the compressing process is complete, right-click on `hub_folder.zip`
25+
in the JupyterHub file browser
26+
and click "Download". You should be able to use your computer's software to unzip
27+
the compressed folder by double-clicking on it.

setup.Rmd

Lines changed: 69 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,15 @@
22

33
## Overview
44

5-
Throughout this book, we have assumed that you are working on a web-based platform,
6-
such as JupyterHub, which already has Jupyter, R, several R packages, and Git set up and ready to use.
7-
In this chapter, you'll learn how to install all of that software on your own computer in case
8-
you don't have a preconfigured JupyterHub available to you.
5+
In this chapter, you'll learn how to install all of that software
6+
needed to do this data science covered in this book on your own computer.
97

108
## Chapter learning objectives
119

1210
By the end of the chapter, readers will be able to:
1311

14-
- install Git and the miniconda Python distribution
12+
- install the Git version control software
1513
- install and launch a local instance of JupyterLab with the R kernel
16-
- download files from a JupyterHub for later local use
17-
1814

1915
## Installing software on your own computer
2016

@@ -25,41 +21,33 @@ we have created instructions for multiple operating systems.
2521
In particular, the installation instructions below have been verified to work
2622
on a computer that:
2723

28-
- runs one of the following operating systems: MacOS 10.15.X (Catalina); Ubuntu 20.04; Windows 10, version 2004.
24+
- runs one of the following operating systems: Ubuntu 20.04, macOS Big Sur (version 11.4.x or 11.5.x), Windows 10 Professional, Enterprise or Education (version 2004, 20H2, or 21H1).
2925
- can connect to networks via a wireless connection
3026
- uses a 64-bit CPU
3127
- uses English as the default language
3228

33-
**For macOS users only:** Apple recently changed the default shell in the terminal to Zsh.
34-
However, the programs we need work better with the Bash shell. Thus, we recommend you change
35-
the default shell to Bash by opening the terminal
36-
([how-to video](https://youtu.be/5AJbWEWwnbY)) and typing:
37-
38-
```
39-
chsh -s /bin/bash
40-
```
41-
42-
You will have to quit all instances of open terminals and then restart the
43-
terminal for this to take effect.
44-
4529
### Git
4630

47-
As shown in Chapter \@ref(Getting-started-with-version-control), Git is a very useful tool for version
48-
controlling your projects, as well as sharing your work with others. Here's how to install Git on
31+
As shown in Chapter \@ref(Getting-started-with-version-control),
32+
Git is a very useful tool for version controlling your projects,
33+
as well as sharing your work with others. Here's how to install Git on
4934
the following operating systems:
5035

5136
**Windows:** To install
5237
Git on Windows, go to <https://git-scm.com/download/win> and download the Windows
5338
version of Git. Once the download has finished, run the installer and accept
5439
the default configuration for all pages.
5540

56-
**MacOS:** To install Git on Mac OS, open the terminal and type the following command:
41+
**MacOS:** To install Git on Mac OS,
42+
open the terminal ([how-to video](https://youtu.be/5AJbWEWwnbY))
43+
and type the following command:
5744

5845
```
5946
xcode-select --install
6047
```
6148

62-
**Ubuntu:** To install Git on Ubuntu, open the terminal and type the following commands:
49+
**Ubuntu:** To install Git on Ubuntu, open the terminal
50+
and type the following commands:
6351

6452
```
6553
sudo apt update
@@ -69,33 +57,37 @@ sudo apt install git
6957

7058
### Miniconda
7159

72-
To run Jupyter notebooks on our computers, we will need to install the web-based platform JupyterLab.
60+
To run Jupyter notebooks on our computers,
61+
we will need to install the web-based platform JupyterLab.
7362
But JupyterLab relies on Python; we can install this via
7463
the [miniconda Python package distribution](https://docs.conda.io/en/latest/miniconda.html).
7564

7665
**Windows:** To install miniconda on Windows, download
77-
the [Python 3.8 64-bit version from here](https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe).
78-
Once the download has finished, run the installer and accept the default
79-
configuration for all pages. After installation, you can open the Anaconda Prompt
66+
the [latest Python 64-bit version from here](https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe).
67+
Once the download has finished, run the installer
68+
and accept the default configuration for all pages.
69+
After installation, you can open the Anaconda Prompt
8070
by opening the Start Menu and searching for the program called
81-
"Anaconda Prompt (miniconda3)". When this opens, you will see a prompt similar to
71+
"Anaconda Prompt (miniconda3)".
72+
When this opens, you will see a prompt similar to
8273
`(base) C:\Users\your_name`.
8374

8475
**MacOS:** To install miniconda on MacOS, download
85-
the [Python 3.8 64-bit version from here](https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.pkg).
76+
the [latest Python 64-bit version from here](https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.pkg).
8677
After the download has finished, run the installer and accept the default
8778
configuration for all pages.
8879

8980
**Ubuntu:** To install miniconda on Ubuntu, we first download
90-
the [Python 3.8 64-bit version from here](https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh).
81+
the [latest Python 64-bit version from here](https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh).
9182
After the download has finished, open the terminal and execute the following
9283
commands:
9384

9485
```
9586
bash path/to/Miniconda3-latest-Linux-x86_64.sh
9687
```
9788

98-
> Note: most often, this file is downloaded to the Downloads directory, and thus the command will look like this:
89+
> Note: most often, this file is downloaded to the Downloads directory,
90+
and thus the command will look like this:
9991
> ```
10092
> bash Downloads/Miniconda3-latest-Linux-x86_64.sh
10193
> ```
@@ -117,42 +109,45 @@ Type the following into the Anaconda Prompt (Windows) or the terminal (MacOS and
117109
118110
```
119111
conda install -c conda-forge -y jupyterlab
120-
conda install -y nodejs=10.*
112+
conda install -y nodejs
121113
pip install --upgrade jupyterlab-git
122-
jupyter lab build
123114
```
124115
125116
To test that your JupyterLab installation is functional, you can type
126-
`jupyter lab` into the Anaconda Prompt (Windows) or terminal (MacOS and Ubuntu) and press enter. This should open a new
117+
`jupyter lab` into the Anaconda Prompt (Windows)
118+
or terminal (MacOS and Ubuntu) and press enter. This should open a new
127119
tab in your default browser with the JupyterLab interface. To exit out of
128120
JupyterLab you can click `File -> Shutdown`, or go to the terminal from which
129-
you launched JupyterLab, hold `Ctrl`, and press `c` twice.
121+
you launched JupyterLab, hold `Ctrl`, and press `C` twice.
130122
131123
### R and the IRkernel
132124
133-
To have R available to you in JupyterLab, you will need to install the R programming language and the IRkernel.
125+
To have R available to you in JupyterLab,
126+
you will need to install the R programming language and the IRkernel R package.
134127
To install these, type the following into
135128
the Anaconda Prompt (Windows) or terminal (MacOS and Ubuntu):
136129
137130
```
138-
conda install -c conda-forge -y r-base
131+
conda install -c conda-forge -y r-base">=4.1.1"
139132
conda install -c conda-forge -y r-irkernel
140133
```
141134
142135
To improve the experience of using R in JupyterLab, we will add an extension
143136
that allows us to setup keyboard shortcuts for inserting text.
144-
By default, this extension creates shortcuts for inserting two of the most common R
137+
By default,
138+
this extension creates shortcuts for inserting two of the most common R
145139
operators: `<-` and `|>`. Type the following in the Anaconda Prompt (Windows)
146140
or terminal (MacOS and Ubuntu) and press enter:
147141
148142
```
149143
jupyter labextension install @techrah/text-shortcuts
150-
jupyter lab build
151144
```
152145
153146
### R packages
154147
155-
To install the packages used in this book, type the following in the Anaconda Prompt (Windows) or terminal (MacOS and Ubuntu) and press enter:
148+
To install the packages used in this book,
149+
type the following in the Anaconda Prompt (Windows)
150+
or terminal (MacOS and Ubuntu) and press enter:
156151
157152
```
158153
conda install -c conda-forge -y \
@@ -166,6 +161,7 @@ conda install -c conda-forge -y \
166161
r-rsqlite \
167162
r-testthat \
168163
r-tidymodels \
164+
r-tidyverse \
169165
r-tinytex \
170166
unixodbc
171167
```
@@ -175,10 +171,23 @@ conda install -c conda-forge -y \
175171
To be able to render `.ipynb` files to `.pdf` you need to install a LaTeX
176172
distribution. These can be quite large, so we will opt to use `tinytex`, a
177173
light-weight cross-platform, portable, and easy-to-maintain LaTeX distribution
178-
based on TeX Live. To install it open JupyterLab by typing `jupyter lab`
174+
based on TeX Live.
175+
176+
**MacOS:** To install `tinytex`
177+
we need to make sure that `/usr/local/bin` is writable.
178+
To do this, type the following in the terminal:
179+
180+
```
181+
sudo chown -R $(whoami):admin /usr/local/bin
182+
```
183+
184+
> *Note: You might be asked to enter your password during installation.*
185+
186+
**All operating systems:**
187+
To install LaTeX open JupyterLab by typing `jupyter lab`
179188
in the Anaconda Prompt (Windows) or terminal (MacOS and Ubuntu) and press enter.
180189
Then from JupyterLab open an R console and type the commands listed below and
181-
press Shift + enter to install `tinytex`:
190+
press `Shift` + `enter` to install `tinytex`:
182191
183192
```
184193
tinytex::install_tinytex()
@@ -203,19 +212,24 @@ tinytex::tlmgr_install(c("eurosym",
203212
"upquote"))
204213
```
205214
206-
## Moving files to your computer
207-
This section will help you
208-
save your work from the JupyterHub web-based platform to your own computer.
209-
210-
First, in JupyterHub, open a terminal by clicking "terminal" in the Launcher tab.
211-
Next, type the following in the terminal to create a
212-
compressed `.zip` archive for the work you are interested in downloading:
215+
**Ubuntu:**
216+
To append the TinyTex executables to our `PATH` we need to edit our `.bashrc file`.
217+
The TinyTex executables are usually installed in `~/bin`.
218+
Thus, add the lines below to the bottom of your `.bashrc` file
219+
(which you can open by `nano ~/.bashrc` and save the file:
213220
214221
```
215-
zip -r hub_folder.zip your_folder
222+
# Append TinyTex executables to the path
223+
export PATH="$PATH:~/bin"
216224
```
217225
218-
After the compressing process is complete, right-click on `hub_folder.zip`
219-
in the JupyterHub file browser
220-
and click "Download". You should be able to use your computer's software to unzip
221-
the compressed folder by double-clicking on it.
226+
> Note: If you used `nano` to open your `.bashrc` file,
227+
follow the keyboard shortcuts at the bottom of the nano text editor
228+
to save and close the file.
229+
230+
## Finishing up installation
231+
232+
It is good practice to restart all the programs you used when installing this
233+
software stack before you proceed to doing your data analysis.
234+
This will ensure all the software and settings you put in place are
235+
correctly sourced. This includes JupyterLab, terminal or Anaconda Prompt.

0 commit comments

Comments
 (0)