O'Reilly logo

Data Manipulation with R - Second Edition by Jaynal Abedin, Kishor Kumar Das

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Vector and matrix operations

Matrix operation is one of the most commonly used mathematical operations that we perform during data processing and data analysis. All of the matrix operations must be conformable for the operation, mathematically.

The following are the rules that must be followed for matrix operations:

  • Addition or subtraction rule: There should be at least two vectors, or matrices with the same dimensions
  • Multiplication rule: There should be at least two vectors or matrices with number of columns of first matrix should be same as the number of rows in second one
  • Element wise multiplication: For element wise multiplication, both matrices must be of the same dimension

The following is the R code to perform matrix operations:

# Creating random ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required