Tuesday 8 August 2017

Data Science Tutorial Part 4 Matrices

  1. Matrices
  1. Matrix: 2D array of data elements
  2. They contain elements of the same atomic types. Though we can create a matrix containing only characters or only logical values, they are not of much use.
  3. We use matrices containing numeric elements to be used in mathematical calculations.
  4. A Matrix is created using the matrix() function.
  5. The basic syntax for creating a matrix in R
    1. matrix(data, nrow, ncol, byrow, dimnames)
  6. Observe below examples
  7. Read elements of matrix

  8. Matrix arithmetic Calculations
  9. We construct the transpose of a matrix by interchanging its columns and rows with the function t 
  1. Cbind is useful to combine columns

  2. we can combine the rows of two matrices if they have the same number of columns with the help of rbind function

  3. We can deconstruct a matrix by applying the c function, which combines all column vectors into one or converting a matrix into vector
Refer http://www.r-tutor.com/r-introduction/matrix or https://cran.r-project.org/doc/manuals/R-intro.html#Arrays-and-matrices

No comments:

Post a Comment