Skip to content

Commit

Permalink
Improve installation + reproducibility instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
Robinlovelace committed Oct 1, 2022
1 parent abe6844 commit bf2af6a
Showing 1 changed file with 40 additions and 6 deletions.
46 changes: 40 additions & 6 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,51 @@ Many thanks to all contributors to the book so far via GitHub (this list will up
During the project we aim to contribute 'upstream' to the packages that make geocomputation with R possible.
This impact is recorded in [`our-impact.csv`](https://github.com/Robinlovelace/geocompr/blob/main/misc/our-impact.csv).

## Reproducing the book
## Downloading the source code

The recommended way to get the source code underlying Geocomputation with R on your computer is by cloning the repo.
You can can that on any computer with [Git](https://github.com/git-guides/install-git) installed with the following command:

```bash
git clone https://github.com/Robinlovelace/geocompr.git
```

An alternative approach, which we recommend for people who want to contribute to open source projects hosted on GitHub, is to install the [`gh` CLI tool](https://github.com/cli/cli#installation).
From there cloning a fork of the source code, that you can change and share (including with Pull Requests to improve the book), can be done with the following command:

```bash
git fork robinlovelace/geocompr # (git clone robinlovelace/geocompr # also works)
```

Both of those methods require you to have Git installed.
If not, you can download the book's source code from the URL https://github.com/Robinlovelace/geocompr/archive/refs/heads/main.zip .
Download/unzip the source code from the R command line to increase reproducibility and reduce time spent clicking around:

```{r dl-unzip, eval=FALSE}
u = "https://github.com/Robinlovelace/geocompr/archive/refs/heads/main.zip"
f = basename(u)
download.file(u, f) # download the file
unzip(f) # unzip it
file.rename(f, "geocompr") # rename the directory
rstudioapi::openProject("geococompr")
```

## Reproducing the book in R/RStudio

To ease reproducibility, we created the `geocompkg` package.
Installing it from GitHub will install all the R packages needed build the book (you will need a computer with necessary [system dependencies](https://github.com/r-spatial/sf#installing) and the [**remotes**](https://github.com/r-lib/remotes/) package installed):
Install it with the following commands:

```{r readme-install-github, eval=FALSE}
install.packages("remotes")
# To reproduce the first Part (chapters 1 to 8):
remotes::install_github("geocompr/geocompkg")
```

Running the commands above should install the packages needed to run the first part of the book (chapters 1 to 8).
To install and build the book in its entirety, run the following command (which installs additional 'Suggests' packages, this may take some time to run!):
Installing `geocompkg` will also install core packages required for reproducing **Part 1 of the book** (chapters 1 to 8).
Note: you may also need to install [system dependencies](https://github.com/r-spatial/sf#installing) if you're running Linux (recommended) or Mac operating systems.
You also need to have the [**remotes**](https://github.com/r-lib/remotes/) package installed:

To reproduce book **in its entirety**, run the following command (which installs additional 'Suggests' packages, this may take some time to run!):

```{r readme-install-github-2, message=FALSE, eval=FALSE, results='hide'}
# To reproduce all chapters (install lots of packages, may take some time!)
Expand All @@ -113,10 +145,12 @@ remotes::install_github("geocompr/geocompkg", dependencies = TRUE)

You need a recent version of the GDAL, GEOS, PROJ and udunits libraries installed for this to work on Mac and Linux.
See the **sf** package's [README](https://github.com/r-spatial/sf) for information on that.

Once the dependencies have been installed you should be able to build and view a local version the book with:
After the dependencies have been installed you should be able to build and view a local version the book with:

```{r readme-render-book, eval=FALSE}
# Change this depending on where you have the book code stored:
rstudioapi::openProject("~/Downloads/geocompr")
# or code //geocompr in the system terminal
bookdown::render_book("index.Rmd") # to build the book
browseURL("_book/index.html") # to view it
```
Expand Down

0 comments on commit bf2af6a

Please sign in to comment.