Learning Objectives
- Creating Vectors
- Creating Matrices
- Performing Some Simple Operations on Vectors & Matrices
Vector
- A vector, in programming, is a type of array that is one-dimensional.
- Now, what are dimensions? - Let’s take an example of a box to explain this. A box has three dimensions width, length, and depth (or height). Similarly, we work with “N” dimensional datasets in data science. “N” could be any number.

Matrix
- Matrix is an arrangement of numbers into rows and columns

You may go through this simple explainer on Khan Academy:
Creating Vector in R
- We can create a vector in R using the c or concatenate command in R.
- See the example below:


Creating Sequence in R
- We can generate a sequence of numbers in R as shown below:

Basic Arithmetic Operations on Vectors

Creating Matrix in R
- We can create a matrix in R using the matrix command.
- See the example below:

-
In the video coming up in the next slide, the tutor will discuss the following things in the hands-on tutorial:
▶︎ How to create vectors in R for numbers or objects using the c function or concatenate function
▶︎ How to use the seq function to create sequence data in R
▶︎ How to use the rep function in R to create a vector of repeated numbers or characters
▶︎ How to create a matrix using matrix function in R and use square brackets to extract certain elements from a matrix in R
▶︎ How to perform basic arithmetic functions on the elements of one vector, perform arithmetic functions on the corresponding elements of two vectors and perform element-wise arithmetic functions in a matrix in R Statistical software.