Question

What would be the R script to reshape a 6 ×24 numeric matrix, say tmp, into...

What would be the R script to reshape a 6 ×24 numeric matrix, say tmp, into a 8 × 6 × 3 array?

A. matrix(tmp,8,6,3) B. array(matrix(tmp,8,6,3)) C. array(tmp, dim=c(8,6,3)) D. as.array(tmp,8,6,3) E. array(tmp, dim=c(3,6,8))

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The answer to the above problem is as follows-

The correct option is C.array(tmp, dim=c(8,6,3))

The options along with explanation is as follows-

A.  matrix(tmp,8,6,3) - Wrong option

Reason - This statement changes the 8*24 matrix to a dimension of 8*6 matrix

B. array(matrix(tmp,8,6,3)) - Wrong option.

Reason - This statement changes the 8*24 matrix to an array of length 48.

C.array(tmp, dim=c(8,6,3)) - CORRECT ANSWER

Explanation - This statement changes the 8*24 matrix to a 8*6*3 dimensional array.

D. as.array(tmp,8,6,3) - Wrong option

Reason - This statement changes the 8*24 matrix to an array of dimension 8*24.So the dimension does not change.

E. array(tmp, dim=c(3,6,8)) - Wrong option.

Reason - This statement changes the 8*24 matrix to an array of dimension 3*6*8. And not 8*6*3. So this is also incorrect option.

If this answer helps, please give an up vote and feel free to comment for any query.

Add a comment
Know the answer?
Add Answer to:
What would be the R script to reshape a 6 ×24 numeric matrix, say tmp, into...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using RStudio, Create an R-Script: (1) You will generate a numeric matrix of size 21 by...

    Using RStudio, Create an R-Script: (1) You will generate a numeric matrix of size 21 by 21 and will name it tmp. To do so, draw 21×21 = 441 random observations from the standard normal distribution. Before doing so, set the seed for the random number generator to 37. See help for set.seed(). (2) Change the diagonal elements of tmp to 1s. (3) Calculate condition number of tmp. See help for cond(). (4) Calculate the inverse of tmp. See help...

  • Using RStudio, Create an R-Script: (1) You will generate a numeric matrix of size 21 by...

    Using RStudio, Create an R-Script: (1) You will generate a numeric matrix of size 21 by 21 and will name it tmp. To do so, draw 21×21 = 441 random observations from the standard normal distribution. Before doing so, set the seed for the random number generator to 37. See help for set.seed(). (2) Change the diagonal elements of tmp to 1s. (3) Calculate condition number of tmp. See help for cond(). (4) Calculate the inverse of tmp. See help...

  • We say that an nxn matrix is skew-symmetric if A^T=-A. Let W be the set of...

    We say that an nxn matrix is skew-symmetric if A^T=-A. Let W be the set of all 2x2 skew-symmetric matrices: W = {A in m2x2(R) l A^T=-A}. (a) Show that W is a subspace of M2x2(R) (b) Find a basis for W and determine dim(W). (c) Suppose T: M2x2(R) is a linear transformation given by T(A)=A^T +A. Is T injective? Is T surjective? Why or why not? You do not need to verify that T is linear. 3. (17 points)...

  • Given the matrix z = [1 5 3,2 4 6:6 9 31, what would be stored...

    Given the matrix z = [1 5 3,2 4 6:6 9 31, what would be stored in sumofz after the following MATLAB command is executed? 33. sumofz sum (z) = a. 39 b. 9 18 12 c. 9 d. 9 12 18 e. none of the above 34. Suppose we had the two MATLAB commands below angls-[0: 0.1*pi: 2 pi] sines-sin(angles) What would be the command to plot angles on the x axis and sines on the y axis? a....

  • help finish the matlab script For this actvity, find the matrix represenatation (T) for the linear...

    help finish the matlab script For this actvity, find the matrix represenatation (T) for the linear transformation T: R3 → R2 defined by T (6) x1 + x2 -2x3 with respect to the ordered bases ={[-] 131 Script Save C Reset MATLAB Documentation 1 %Create the augmented matrix D, whose columns are the ordered basis of C followed 2 %by the image of the ordered basis of B. 3 4 %Row reduce the augmented matrix to get [I | T_Btoc]....

  • (a) Why is it impossible for a 3 x 4 matrix A to have rank 4...

    (a) Why is it impossible for a 3 x 4 matrix A to have rank 4 and dim Nul A = 0? (b) What is the rank of a 6 x 8 matrix whose null space is three-dimensional? (c) If possible, construct a 3 x 5 matrix B such that dim Nul B =3 and rank B = 2. Explain your reasoning. (d) Construct a 4 x 3 matrix C with rank 1. It need not be complicated.

  • What is the R code and result in Rstudio 1. The following data gives, for each...

    What is the R code and result in Rstudio 1. The following data gives, for each amount by which an elastic band is stretched over the end of a ruler, the distance that the band moved when released: stretch 46 54 48 50 44 4 52 distance 148 182 173166 109 141 166 Create a data frame in R with two columns that contain "stretch and "dis tance" respectively. Plot the distance versus the stretch using plot) function What trend...

  • matlab help Write a script to manipulate the array A = [2 1 4 3 6...

    matlab help Write a script to manipulate the array A = [2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19] to be in descending order without using the sort function. You must do everything using array manipulation in MATLAB (i.e. you cannot sort it by hand and then hardcode it, you cannot simply create the array 1:20, you cannot simply add .rej3mat(J-l 1],1,10) to A). Write a script that...

  • Please solve them clear . 1. Consider the matrix A = [ 24 31. a) (7...

    Please solve them clear . 1. Consider the matrix A = [ 24 31. a) (7 pnts) Find the characteristic polynomial of A. b) (7 pnts) Compute the matrix B = A- 2A +812. c) (6 pnts) Can you describe how to find the inverse of A using characteristic equation? 2. a) (7 pnts) Solve the second order homogeneous linear differential equation y" - y = 0. b) (6 pnts) Without any solving, explain how would you change the above...

  • What is the Rcode and result in Rstudio 3. What is the difference between a vector...

    What is the Rcode and result in Rstudio 3. What is the difference between a vector and a list in R? What about the difference between a matrix and a dataframe in R? Without using R, provide the output from the following command in R: 16; d = array(c, dim = c(2,4, 2))an,2, 5. Explain the connection between z and y, where = qnorm(5); y = pnorm (0

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT