Solution Review: Arrays and Matrices
Learn how to effectively create and manipulate arrays and matrices in R by reviewing solutions that use vectors and dimension arguments. Understand how to pass vectors to the array function and control matrix dimensions in R programming.
We'll cover the following...
We'll cover the following...
Solution #1: Using vectors
Explanation
Simply make three vectors and pass them to array(). Also, set the specific dimensions. Notice that the last argument to dim is because we want just one matrix.
Solution #2: Using vector
Explanation
We can also use only one vector, populate it, and pass it to array(). However, the dim argument remains the same because we want one matrix.