Categories Pricing Corporate
Free Textbook

A Step-by-Step R Tutorial

An introduction into R applications and programming

2 reviews
Language:  English
A Step-by- Step Tutorial in R has a two-fold aim: to learn the basics of R and to acquire basic skills for programming efficiently in R.
Download free PDF textbooks or read online. Less than 15% adverts
Business subscription free for the first 30 days, then $5.99/mo

A Step-by- Step Tutorial in R has a two-fold aim: to learn the basics of R and to acquire basic skills for programming efficiently in R. Emphasis is on converting ideas about analysing data into useful R programs. It is stressed throughout that programming starts first by getting a clear understanding of the problem. Once the problem is well formulated the next phase is to write step-by-step code for execution by the R evaluator. Although A Step-by-Step Tutorial in R is primarily intended as a course directed by an instructor, it can also be used  with a little more effort  as a self-teaching option. The first 11 chapters form the core and deal with management of R objects, workspaces, functions, graphics, data structures, subscripting, search paths, evaluation environments, vectorised programming, mapping functions, loops, error tracing and statistical modelling. The optional final chapters take a closer look at analysis of variance and covariance and optimization techniques.

  • Preface
  1. Introducing the R system
    1. Introduction
    2. Downloading the R system
    3. A quick sample R session
    4. R: an interpretive computer language
    5. A closer look at the R console
    6. More R basics
    7. Regular expressions in R: the basics
    8. From single instructions to sets of instructions: introducing R functions
    9. R within the Windows environment
    10. Working with RStudio
    11. Using R Commander
    12. Activating an R project
    13. A note on computations by a computer
    14. Built-in data sets in R
    15. The use of .First() and .Last()
    16. Options
    17. R output (text and graphics) to Microsoft Word
    18. Creating PDF and HTML documents from R output:
    19. R package knitr
    20. Creating PDF and HTML documents from R output: R Markdown
    21. Command line editing
  2. Managing objects
    1. Creating separate workspaces for each project
    2. Instructions and objects in R
    3. How R finds data
    4. The organisation of data (data structures)
    5. Time series
    6. The functions and
    7. Simple manipulations; numbers and vectors
    8. Objects, their modes and attributes
    9. Representation of objects
    10. Exercise
  3. R operators and functions
    1. Arithmetic operators
    2. Logical operators
    3. The operators <-, <<- and ~
    4. Operator precedence
    5. Introduction to functions in R
    6. Some mathematical functions
    7. Differentiation and integration
    8. Exercise
  4. Introducing traditional R graphics
    1. General
    2. High-level plotting instructions
    3. Interactive communication with graphs
    4. 3D graphics: package rgl
    5. Exercise
  5. Subscripting
    1. Subscripting with vectors
    2. Subscripting with matrices
    3. Extracting elements of lists
    4. Extracting elements from dataframes
    5. Combining vectors, matrices, lists and dataframes
    6. Rearranging the elements in a matrix
    7. Exercise
  6. Revision tasks
    1. Guidelines for problem solving by writing R code
    2. Exercise
  7. Writing functions in R
    1. General
    2. Writing a new function
    3. Checking for object name clashes
    4. Returning multiple values
    5. Local variables and evaluation environments
    6. Cleaning up
    7. Variable number of arguments: argument …
    8. Retrieving names of arguments: functions deparse() and substitute()
    9. Operators
    10. Replacement functions
    11. Default values and lazy evaluation
    12. The dynamic loading of external routines
  8. Vectorized programming and mapping functions
    1. Mapping functions to a matrix
    2. Mapping functions to vectors, dataframes and lists
    3. The functions: mapply(), rapply() and Vectorize()
    4. The mapping function tapply() for grouped data
    5. The control of execution flow statement if-else and the control functions ifelse() and switch()
    6. Loops in R
    7. The execution time of R tasks
    8. The calling of functions with argument lists
    9. Evaluating R strings as commands
    10. Object oriented programming in R
    11. Recursion
    12. Environments in R
    13. “Computing on the language”
    14. Writing user friendly applications: the package shiny
    15. Exercise
    16. The function on.exit()
    17. Error tracing
    18. Error handling: The function try()
  9. Reading data files into R, formatting and printing
    1. Reading Microsoft Excel files into R
    2. Reading other data files into R
    3. Sending output to a file
    4. Writing R objects for transport
    5. The use of the file .Rhistory and the function history()
    6. Command re-editing
    7. Customized printing
    8. Formatting numbers
    9. Printing tables
    10. Communicating with the operating system
    11. Exercise
    12. Tidyverse
    13. Exercise
  10. R graphics: Round II
    1. Graphics parameters
    2. Layout of graphics
    3. Low-level plotting commands
    4. Using the plotting commands
    5. Quantile plots
    6. Estimating a density
    7. A coplot with two conditioning variables
    8. Exact distances in graphics
    9. Multiple graphics windows in R
    10. More complex layouts
    11. Dynamic 3D graphics in R
    12. Animation
    13. Exercise
    14. The package ggplot2
    15. Exercise
  11. Statistical modelling with R
    1. Introduction
    2. Data for statistical models
    3. Expressing a statistical model in R
    4. Common arguments to R modelling functions
    5. Using the statistical modelling objects
    6. Usage of the function with()
    7. Linear regression and anova
    8. Regression diagnostics
    9. Non-parametric regression
    10. The function glm()
    11. The function gam()
    12. The function rpart()
    13. Nonlinear regression and the function nls()
    14. Detailed example: Analysis of Variance and Covariance
  12. Introduction to Optimization
    1. The bisection method for solving
    2. The Newton-Raphson method
    3. The R functions optim()and constrOptim()
    4. Packages quadprog, lpSolve and Rsolnp for constrained optimization
  • References
  • Endnotes
The best book for my course
Excellent for studying computer programming.
More reviews
About the Authors

Sugnet Lubbe

Niël J le Roux