Load the library of GISTools

url<-"https://cran.r-project.org/src/contrib/Archive/GISTools/GISTools_0.7-4.tar.gz"
pkgFile<- "GISTools_0.7-4.tar.gz"
download.file(url = url, destfile = pkgFile)

# Install dependencies list in the DESCRIPTION file
install.packages(c("maptools", "sp", "RColorBrewer", "MASS", "rgeos"))

# Install package
install.packages(pkgs=pkgFile, type="source", repos=NULL, INSTALL_opts ='--no-lock')

# Delete package tarball
unlink(pkgFile)

# Load the package
library(GISTools)

2. Data and Plots

2.1 Introduction

This chapter introduces some of the different data types and data structures that are commonly used in R and how to visualise them. As you work through this book, you will gain experience in using and manipulating these individually and within blocks of code. It sequentially builds on the ideas that are introduced, for example developing your own functions, and tests this knowledge through self-test exercises. As you progress, the exercises will place more emphasis on solving problems, using the different data structures needed, rather than simply working through the example code. As you work though the code, you should use the help available to explore the different functions that are called in the code snippets, such as max, sqrt and length.

This chapter covers a lot of ground – it will:

Review basic commands in R Introduce variables and assignment Introduce data types and classes Describe how to test for and manipulate data types Introduce and compare data frames and tibbles Introduce basic plot commands Describe how to read, write, load and save different data types

Chapter 1 introduced R, the reasons for using it in spatial analysis and mapping, and described how to install it. It also directed you to some of the many resources and introductory exercises for undertaking basic operations in R. Specifically it advised that you should work through the ‘Owen Guide’ (entitled The R Guide) up to the end of Section 5. This can be accessed via https://cran.r-project.org/doc/contrib/Owen-TheRGuide.pdf. This chapter assumes that you have worked your way through this – it does not take long and provides critical introductory knowledge for the more specialised materials that will be covered in the rest of this book.

x<-3+2
print(x)
## [1] 5