Create following two matrices A and B with following elements.
A=,B=
Write R commands to do the following tasks:
(i) Multiply the two matrices.
(ii) Combine the two matrices row-wise.
(iii) Create a function that computes the following expression:
A 2+3*B
| X | Y | Z | W |
| 0.04 | 0.16 | 0.53 | A |
| 0.82 | 0.87 | 0.84 | A |
| 0.32 | 0.65 | 0.99 | A |
| 0.39 | 0.83 | 0.42 | A |
| 0.31 | 0.93 | 0.78 | A |
| 0.83 | 0.31 | 0.41 | A |
| 0.73 | 0.74 | 0.88 | A |
| 0.32 | 0.39 | 0.50 | B |
| 0.60 | 0.85 | 0.68 | B |
| 0.65 | 0.28 | 0.86 | B |
| 0.55 | 0.95 | 0.77 | B |
| 0.53 | 0.35 | 0.32 | B |
| 0.91 | 0.01 | 0.91 | B |
| 0.84 | 0.61 | 0.37 | B |
Write R commands to:
(i) Compute the group wise means of x, y and z according to the groups
defined by w column using apply family function.
(ii) Sort RData according the y column of it.
To perform the tasks outlined in the question using R, you can follow these steps:
1. Create Matrices A and B:
# Create matrices A and B
A <- matrix(c(1, 2, 0, 1), nrow = 2, ncol = 2, byrow = TRUE)
B <- matrix(c(-3, 1, 2, -1), nrow = 2, ncol = 2, byrow = TRUE)
2. Multiply the two matrices (i):
# Multiply matrices A and B
result <- A %*% B
3. Combine the two matrices row-wise (ii):
# Combine matrices A and B row-wise
combined ______ ____ ________ _______ _____ _________ ____.
___ ____ ___ ________ __________ ____ _________ ______ ______.
__________ _______ _________ ______ _________ ___ ______.
______ ______ _________ _______ ___.
___ __________ _________ ____ ________ _____ _____ ______ ______ ____.
______ _______ ______ ____ ___ ____.
_________ ___ _________ _______ __________ ___ _______ __________ ______ ______ ______.
__________ ____ _______ ____ ___ _____ ___ ____ _______ ______ ______ __________.
_______ _____ _____ ____ _____ _____ _____ __________ ___ _______ ______.
__________ __________ _________ __________ _______ ______ ______.
____ _______ ____ ____ ___ ______.
__________ __________ __________ _________ __________ ________ ________.
___ ______ _______ ____ ______ ____ _________ _________.
____ ______ ____ ____ ___ ______ __________ ______ __________ __________ _____.
__________ _____ ___ ________ _______ _______ _______ ___ ___ _________ ________.
______ _________ _____ _________ _______ _______ ___.
__________ _______ _____ ____ _______ __________.
_________ _________ ____ __________ ______ ________ ________ _____ _______.
______ ____ ____ ________ ______ ______ ___ ________ ____.
___ __________ ___ __________ _____ ________ _____ _____.
_________ ________ ________ ___ _______ ____ __________ _______ ____.
______ ______ __________ ________ _________ _____ _______ __________ ______.
_______ _______ ______ _______ ____ __________ ____ _________ ______.
______ ___ ______ __________ _______ ___ _______ _______ ______ _________ _______ ___.
___ __________ ___ ____ ___ ____.
________ ______ _____ _______ ___ _______ _____ ____ ______ ____ _________.
_____ _______ ___ ___ ___.
____ ________ ___ __________ __________ ___ __________ _______.
___ _____ ________ ___ ____.
_________ _________ __________ _____ _________ _________ ____ ____ ________ ___ ____ ________.
_________ _____ ________ _________ __________ __________ ___ ________ ___.
______ ____ ____ _________ ____ ____ _________ ________ __________ _____ _____ _______.
_________ _______ __________ _______ ______.
Get Full Answer on WhatsApp