Question: RStudio Question: I am trying to use a loop to populate a matrix of NA values. I know it isn't the best way to do
RStudio Question: I am trying to use a loop to populate a matrix of NA values. I know it isn't the best way to do this but this is the method I must use. Below is what I have so far but I am not sure what to put in the loop. For simplicity, I just want a list from 1 to 20.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
n = 20; M = matrix(NA, ncol = 2, nrow = 10);
for (i in 1:n){ # store seq(1, 20) into matrix <--- help here } M
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The goal is to produce the same matrix as this code:
data <- seq(1, 20) M = matrix(data, ncol =2, nrow = 10) M
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
