Question: In R Provide a script that (i) creates a matrix m with 300x300 random elements (ii) creates a data frame df with the same elements

In R

Provide a script that

(i) creates a matrix m with 300x300 random elements

(ii) creates a data frame df with the same elements in v using as.data.frame(m)

(iii) build two nested for loops that simply adds all the values in m and save the result in a variable x

(iv) collect the time for that block of code

(v) collect the size (memory) of m

(vi) do the same for the data frame dm Repeat the process for the sizes 300x300, 320x320, 340x340, 360x360, , 500x500 (11 data points).

Plot two graphs using the plot function (and other required function to get the job done, e.g. legend, title, lines):

a) one comparing the matrix vs. data frame memory usage

b) one comparing the matrix vs. data frame running time.

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 Databases Questions!