Menu


R Codes for Statistics and Data Visualization in Climate Science


Steps To Download the R code for the entire book:

(i) Right click on the link
(ii) Select "Save Page As" from the File drop-down menu
(iii) Choose your destination folder, change your file name to .R, click "Save"
(iv) Run the R code on RStudio. Some parts of the R code need to read datasets. Thus, you have to download the data.zip file before you run that part of the code. Unzip the file to obtain the data folder, which contains all the datasets needed to run the R code. You also need to place the data folder in your working directory, which may be named climstats. Accordingly, you need to enter your correct working directory path in your R code, e.g., setwd("/Users/sshen/climstats").

Download the .zip file of the R code for the entire book:

(i) Right click on the link to download the RCodeClimStats.R.zip file
(ii) Go to your Downloads folder to find the file named RCodeClimStats.R.zip
(iii) Unzip the RCodeClimStats.R.zip file to obtain RCodeClimStats.R
(iv) Run RCodeClimStats.R on RStudio. Some parts of the R code need to read datasets. Thus, you have to download the data.zip file before you run that part of the code. Unzip the file to obtain the data folder, which contains all the datasets needed to run the R code. You also need to place the data folder in your working directory, which may be named climstats. Accordingly, you need to enter your correct working directory path in your R code, e.g., setwd("/Users/sshen/climstats").

Chapter-by-chapter display of the R dode and graphics for you to copy-and-paste into your RStudio:
(Momtaza Sayd produced the html files below. Matthew Meier updated this website.)

Chapter 1: Basics of Climate Data Arrays, Statistics, and Visualization
Chapter 2: Elementary Probability and Statistics
Chapter 3: Estimation and Decision Making
Chapter 4: Regression Models and Methods
Chapter 5: Matrices for Climate Data
Chapter 6: Covariance Matrices, EOFs, and PCs
Chapter 7: Introduction to Time Series
Chapter 8: Spectral Analysis of Time Series
Chapter 9: Introduction to Machine Learning



Citation: Shen, S.S.P., and G.R. North, 2023: Statistics and Data Visualization in Climate Science with R and Python, Cambridge University Press, Cambridge, United Kingdom, 391pp.