Question: 9 . Create a 1 0 0 0 0 0 by 1 0 matrix with the numbers 1 : 1 0 0 0 0 0

9. Create a 100000 by 10 matrix with the numbers 1:1000000. Make a for-loop that calculates the sum for
each row of the matrix and stores the results in a list rowAdd. Verify that your results are consistent with
what you obtain with the apply function to calculate row sums as well as with the built-in rowSums function.
Side Note: In R, always pre-allocate your vectors and update the values instead of creating an empty vector
and appending to it which is a significantly slower operation.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!