For these exercises, you need to have a basic understanding of R objects and functions, in particular some knowledge about
If you obtained a different (correct) answer than those listed on the solutions page, please feel free to post your answer as a comment on that page.
Construct a matrix of 10 rows by 10 columns filled with random numbers between 0 and 1, uniformly distributed. Plot it using the
Costumize the plot by changing from colours to grayscale and equally space the squares.
Construct a matrix of 5 rows by 5 columns with random numbers as in exercise 1, and create a contour plot.
To create a 3d plot with the
persp function, we need 3 variables (x,y,z) where z is a matrix that contains values to be plotted. Try to replicate this plot (hint: the relation between x,y and z is defined by: z <- (x+y)/2:
Now let’s customize our 3d plot, modifying some details such as background colour and values colours. Then change the way to define x and y variables. The final result it should be like this:
Let’s take our last 3d plot and add some details as labels and plot orientation (hint: phi value). Final result should be like this:
For the final exercise we have to reproduce the 3d plot below using what we have learned in the previous exercises: