Matrix R Assignment Instructions:
1. Form a vector of 56 normally distributed numbers with a mean of 5 and a standard deviation
of 20. Create a 7 column matrix with the values.
2. Name the rows of the matrix created in the last question with the letters from a to h, and the
columns with the letters from i to o.
3. Create four vectors of 8 discrete random numbers between 10 and 80. Create matrices with
the four vectors using both the rbind() and cbind() functions.
4. Create a 5x5 matrix that contains 25 discrete random numbers between 10 and 80, without
replacement. Access the data values instructed below:
matrix1 = matrix(10:80, nrow = 5, byrow = FALSE)
- row 2, column 4
- row 4, columns 2 to 4
- column 4, rows 1 to 5
- row 3
- column 3
- intersection between rows 1 and 3 with columns 4 and 5
Create a vector containing the 10th, the 12th, and the 14th element of the matrix.
x = sample(10:80,25,replace=FALSE)
matrix1 = matrix(x,nrow=5,byrow=FALSE)
vector=c(matrix1[5,2], matrix1[2,3], matrix1[4,3])
5. In the matrix created in the previous question do the following:
- compute the sum and the mean for each row and column, respectively
- compute the cumulative sum for each row and column, respectively
- compute the square root of each data element row-wise, and store the results in a
new matrix
- compute the logarithm of each data element row-wise, and store the results in a
new matrix
Hint: use the apply() function.
6. Create a 4x5 matrix with any values and a 5x3 matrix with any values. Multiply them using
the special multiplication operator. What are the dimensions of the new matrix?