1 of 14

Introduction

  • To participate in the workshop, you must have all the packages listed in this installation guide installed.

  • Slides 2 through 7 serve as a guide for installing the required packages in R/RStudio on Windows.

  • Instructions for Mac users can be found starting on slide 8.

2 of 14

Installation

  • Installing R and Rstudio on Windows

Please use the following link to access instructions for installing R and RStudio on a Windows:

https://teacherscollege.screenstepslive.com/a/1108074-install-r-and-r-studio-for-windows

  • Update R if you do not have the latest version

> install.packages("installr")

> require(installr)

> updateR()

3 of 14

  • RTools

(Please note that 'Rtools' is a package for Windows and is not necessary for Mac.)

Download RTools4.0 from this address:

https://cran.r-project.org/bin/windows/Rtools/rtools40.html

Run ".exe" file as admin and install it.

Open Rstudio and run the line below in it:

write('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', file = "~/.Renviron", append = TRUE)

After running the code close Rstudio.

Now open the Rstudio again and verify that make can be found:

Sys.which("make")

4 of 14

  • lidR, raster and rgdal in R/Rstudio

> install.packages("lidR", type = "source") or install.packages("lidR")

> install.packages("raster", type = "source") or install.packages("raster")

> install.packages("rgdal", type = "source") or install.packages("rgdal", type="binary")

5 of 14

    • rlang library in R/Rstudio

> install.packages("remotes")

> remotes::install_github("r-lib/rlang")

    • RMCC package in R/Rstudio

> install.packages("RMCC")

    • starts and terra in R/Rstudio

> install.packages("stars")

> install.packages("terra")

    • Install rayshader in R/Rstudio

> install.packages("devtools", type = "win.binary")

or

> install.packages("devtools")

> devtools::install_github("tylermorganwall/rayshader")

or

> install_github("tylermorganwall/rayshader", INSTALL_opts="--no-multiarch")

6 of 14

    • dplyr, mom, gmp, Rdimtools, and RCSF in R/Rstudio

> install.packages("dplyr")

> install.packages("lmom")

> install.packages("gmp",type="binary")

> install.packages("Rdimtools")

> install.packages("RCSF")

> install.packages("ggplot2")

7 of 14

Double-check if the packages are installed

By running:

> library(lidR)

> packageVersion("lidR")

> library(raster)

> library(rgdal)

> library(rlang)

> library(ggplot2)

> library(dplyr)

> library(lmom)

> library(Rdimtools)

> library(terra)

> library(rayshader)

8 of 14

Installing R and Rstudio on Mac

Please use the following link to access instructions for installing R and RStudio on a Mac:

https://teacherscollege.screenstepslive.com/a/1135059-install-r-and-r-studio-for-mac

9 of 14

To install the lidR package in R on a Mac, you can follow these steps:

  1. Open R: Open R by clicking on its icon in your Applications folder or by using Spotlight search.
  2. Install the devtools package: Run the following command in the R console to install the ‘devtools’ package:

> install.packages("devtools")

  • Install lidR: Run the following command in the R console to install lidR:

> install.packages("lidR")

  • This command will download and install the latest version of the lidR package from the GitHub repository.
  • Load lidR: After installation is complete, you can load the lidR package by running the following command in the R console:

> library(lidR)

10 of 14

Installing r package that has c/c++ code (optional)

However, if you are trying to build an R package that has C/C++ code, you may need to install additional tools on your Mac to build and compile the code. Here are the steps to install the necessary tools:

  1. Install Xcode: Xcode is Apple's integrated development environment (IDE) for macOS. It includes compilers and other tools needed to build software. You can download Xcode from the Mac App Store or from the Apple Developer website.
  2. Install Command Line Tools for Xcode: After installing Xcode, open Terminal and run the following command:�

> xcode-select --install�

This will prompt you to install the Command Line Tools for Xcode.

  • Install Homebrew: Homebrew is a package manager for macOS that makes it easy to install software packages. Open Terminal and run the following command to install Homebrew:

�/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

  • Install additional tools: After installing Homebrew, you can use it to install additional tools needed for building R packages. To install the necessary tools, run the following commands in Terminal:

> brew install gcc

> brew install gfortran

These commands will install the GNU Compiler Collection (gcc) and the GNU Fortran compiler (gfortran).

11 of 14

  • raster and rgdal in R/Rstudio

> install.packages("raster", type = "source")

> install.packages("rgdal", type = "source") or install.packages("rgdal", type="binary")

12 of 14

    • rlang library in R/Rstudio

> install.packages("remotes")

> remotes::install_github("r-lib/rlang") or install.packages("rlang")

    • RMCC package in R/Rstudio

> install.packages("RMCC")

    • starts and terra in R/Rstudio

> install.packages("stars")

> install.packages("terra")

    • Install rayshader in R/Rstudio

> install.packages("devtools")

> devtools::install_github("tylermorganwall/rayshader")

or

> install_github("tylermorganwall/rayshader", INSTALL_opts="--no-multiarch")

13 of 14

    • dplyr, mom, gmp, Rdimtools, and RCSF in R/Rstudio

> install.packages("dplyr")

> install.packages("lmom")

> install.packages("gmp",type="binary")

> install.packages("Rdimtools")

> install.packages("RCSF")

> install.packages("ggplot2")

14 of 14

Double-check if the packages are installed

By running:

> library(lidR)

> packageVersion("lidR")

> library(raster)

> library(rgdal)

> library(rlang)

> library(ggplot2)

> library(dplyr)

> library(lmom)

> library(Rdimtools)

> library(terra)

> library(rayshader)