Matrix Notation Exercises
Exercises
-
In R we have vectors and matrices. You can create your own vectors with the function c.
c(1,5,3,4)They are also the output of many functions such as:
rnorm(10)You can turn vectors into matrices using functions such as rbind, cbind or matrix.
Create the matrix from the vector 1:1000 like this:
X = matrix(1:1000,100,10)What is the entry in row 25, column 3?
-
Using the function cbind, create a 10 x 5 matrix with first column
x=1:10. Then add2*x,3*x,4*xand5*xto columns 2 through 5. What is the sum of the elements of the 7th row? -
Which of the following creates a matrix with multiples of 3 in the third column?
- A)
matrix(1:60,20,3) - B)
matrix(1:60,20,3,byrow=TRUE) - C)
x=11:20; rbind(x,2*x,3*x) - D)
x=1:40; matrix(3*x,20,2)
- A)