R and MATLAB

Book description

This book is designed for users who already know R or MATLAB® and now need to learn the other platform. The author covers essential tasks, such as working with matrices and vectors, writing functions and other programming concepts, graphics, numerical computing, and file input/output. He highlights important differences between the two platforms and explores common mistakes that are easy to make when transitioning from one platform to the other.

Table of contents

  1. Cover
  2. Half Title
  3. Title Page
  4. Copyright Page
  5. Dedication Page
  6. Contents
  7. List of Figures
  8. List of Tables
  9. Preface
  10. About the Author
  11. 1 Installing and Running R and MATLAB
    1. 1.1 Obtaining and installing
    2. 1.2 Commands for getting help
    3. 1.3 Demos
    4. 1.4 Quitting
    5. 1.5 Additional resources
  12. 2 Getting Started: Variables and Basic Computations
    1. 2.1 Variable names
    2. 2.2 Assignment statements
    3. 2.3 Basic computations
    4. 2.4 Formatting of output
    5. 2.5 Other computations
    6. 2.6 Complex numbers
    7. 2.7 Strange variable names in R
    8. 2.8 Data types
      1. 2.8.1 R
      2. 2.8.2 MATLAB
  13. 3 Matrices and Vectors
    1. 3.1 Overview
    2. 3.2 Creating vectors
    3. 3.3 Working with vectors
    4. 3.4 Creating matrices
    5. 3.5 Working with matrices
    6. 3.6 Reshaping matrices, and higher-dimensional arrays
    7. 3.7 Sparse matrices
    8. 3.8 Names with vectors and matrices/arrays
      1. 3.8.1 R: names for vector/matrix elements and matrix rows/columns
      2. 3.8.2 R data frames
      3. 3.8.3 MATLAB structs
    9. 3.9 Miscellaneous
  14. 4 Matrix/Vector Calculations and Functions
    1. 4.1 Applying a function to rows or columns of a matrix
    2. 4.2 Applying a function to all elements of a matrix
    3. 4.3 Linear algebra calculations with vectors and matrices
    4. 4.4 Statistical calculations
    5. 4.5 Vectorized logical tests
    6. 4.6 Other calculations
  15. 5 Lists and Cell Arrays
    1. 5.1 Creating lists and cell arrays
    2. 5.2 Using lists and cell arrays
    3. 5.3 Applying functions to all elements of lists and cell arrays
    4. 5.4 Converting other data types to lists and cell arrays
      1. 5.4.1 All values in a numeric vector or matrix
      2. 5.4.2 Matrix, by columns or rows
    5. 5.5 Converting lists and cell arrays to other data types
      1. 5.5.1 Set of vectors to a single vector
      2. 5.5.2 Set of vectors to matrix
      3. 5.5.3 Set of sets to matrix
      4. 5.5.4 Set of strings to a set of numeric vectors
  16. 6 Flow Control
    1. 6.1 Conditional (“if”) statements
    2. 6.2 “If/else” statements
    3. 6.3 “for” loops
    4. 6.4 “while” loops
    5. 6.5 Breaking out of loops
    6. 6.6 “switch” statements
    7. 6.7 “ifelse” statements in R
  17. 7 Running Code from Files: Scripts
    1. 7.1 Current working directory
    2. 7.2 The MATLAB search path
    3. 7.3 Executing code from a file
    4. 7.4 Creating a new script document in the editor
    5. 7.5 Comments in script files
    6. 7.6 Executing code from the editor window
    7. 7.7 Summary of differences
  18. 8 Writing Your Own Functions
    1. 8.1 R
      1. 8.1.1 Writing functions
      2. 8.1.2 Calling functions
      3. 8.1.3 Environments and variable scope
      4. 8.1.4 Static variables
      5. 8.1.5 Variable arguments
    2. 8.2 MATLAB
      1. 8.2.1 Inline and anonymous functions
      2. 8.2.2 Writing functions
      3. 8.2.3 Calling functions
      4. 8.2.4 Environments and variable scope
      5. 8.2.5 Static variables
      6. 8.2.6 Variable arguments
      7. 8.2.7 Function handles
    3. 8.3 Summary of main differences
  19. 9 Probability and Random Numbers
    1. 9.1 Basic random values, permutations, and samples
    2. 9.2 Random number seed
    3. 9.3 Random variates from probability distributions
    4. 9.4 PDFs, CDFs, and inverse CDFs
  20. 10 Graphics
    1. 10.1 Creating, selecting, and closing figure windows
      1. 10.1.1 Creating windows
      2. 10.1.2 Listing and selecting windows
      3. 10.1.3 Closing windows
    2. 10.2 Basic 2-D scatterplots
    3. 10.3 Adding additional plots to a figure
    4. 10.4 Axis ranges
    5. 10.5 Logarithmic axis scales
    6. 10.6 Background grid
    7. 10.7 Plotting multiple data sets simultaneously
    8. 10.8 Axis labels and figure titles
    9. 10.9 Adding text to figures
    10. 10.10 Greek letters and mathematical symbols
    11. 10.11 Arrows
    12. 10.12 Figure legends
    13. 10.13 Size and font adjustments
    14. 10.14 Two y axes
    15. 10.15 Plotting functions
    16. 10.16 Image plots and contours
    17. 10.17 Colormaps
    18. 10.18 3-D plotting
    19. 10.19 Multiple subplots in one figure
    20. 10.20 Saving figures
    21. 10.21 Other types of plots
    22. 10.22 Final notes about graphics
  21. 11 Numerical Computing
    1. 11.1 Root-finding
      1. 11.1.1 Something to watch out for
    2. 11.2 Univariate optimization
    3. 11.3 Multivariate optimization
    4. 11.4 Numerical integration
    5. 11.5 Curve fitting
      1. 11.5.1 Piecewise linear interpolation
      2. 11.5.2 Polynomial fitting
      3. 11.5.3 Splines
    6. 11.6 Differential equations
  22. 12 File Input and Output
    1. 12.1 Opening files
    2. 12.2 Reading a table of numbers
      1. 12.2.1 Subsets of a data file
    3. 12.3 Reading numeric data with a different comment character
    4. 12.4 Reading numbers from a file where different lines have varying numbers of values
    5. 12.5 Reading numbers and strings
    6. 12.6 Reading the raw character data in, a line at a time
    7. 12.7 Writing a table of numbers
    8. 12.8 Writing a set of strings
    9. 12.9 Saving and loading variables in binary format
    10. 12.10 Images R
    11. 12.11 URLs
    12. 12.12 Excel files
  23. 13 Miscellaneous
    1. 13.1 Working with variables
    2. 13.2 Character strings
    3. 13.3 Reading user input
    4. 13.4 Recording a copy of commands and output
    5. 13.5 Date calculations
    6. 13.6 Miscellaneous
    7. 13.7 Debugging
    8. 13.8 Startup and shutdown sequences
    9. 13.9 Add-ons: packages and toolboxes
    10. 13.10 Object-oriented programming
    11. 13.11 Other interfaces
    12. 13.12 Efficiency/performance
  24. 14 Calling C
    1. 14.1 R
      1. 14.1.1 Example and overview
      2. 14.1.2 Printing, warnings, and errors
      3. 14.1.3 Random numbers
      4. 14.1.4 More advanced features
    2. 14.2 MATLAB
      1. 14.2.1 Example and overview
      2. 14.2.2 Printing, warnings, and errors
      3. 14.2.3 Random numbers
  25. Bibliography
  26. Index of R commands, variables, and symbols
  27. Index of MATLAB commands, variables, and symbols

Product information

  • Title: R and MATLAB
  • Author(s): David E. Hiebeler
  • Release date: September 2018
  • Publisher(s): Chapman and Hall/CRC
  • ISBN: 9781315360355