Question 1:
A). R-markdown
Create a Rmarkdown File (name it as “R Assignment”)
Keep knitting by answring following questions..
Question 2: Manipulating Arrays
A). Set a variable student no equal to your student number (as an integer). Run the following code to
seed the random number generator.
set.seed(500455)
B). Create a random vector with 35 elements using the function runif(). Print your vector as below (its
entries will be different to the one below example).
My vector:
[1] 0.13657 0.84154 0.14272 0.49104 0.51371 0.12455 0.26841 0.42449
[9] 0.55263 0.23255 0.58731 0.27877 0.06764 0.45776 0.84827 0.89885
[17] 0.19844 0.29119 0.19489 0.08537 0.59395 0.05255 0.90160 0.33161
[25] 0.05589 0.14042 0.58746 0.50247 0.17255 0.67475 0.12326 0.12625
[33] 0.42804 0.00201 0.46450
C). Print the following elements of your vector. Be sure to format the result in the same way as shown
below, including the labels Minimum value, etc.
Minimum value: 0.002009551. Maximum value: 0.9015985
Average value: 0.3655426. Median value: 0.2911931
D). Choose a random number (called n) between 8 and 12 using sample(). Print the nth smallest and
nth largest value in the vector.
The 11th smallest value: 0.1427226
The 11th largest value: 0.5024719
E). Reshape your vector into a 5 by 7 matrix. Calculate the following characteristics of your matrix.
Column 3 has the largest sum of all the columns.
Row 4 has the smallest sum of all the rows.
F). Create a new matrix, which is the same as the previous matrix, except that any element m[i,j] that
is greater than 0.4 is replaced with m[i,j]-1. Print the sum of the matrix.
The sum of the new matrix is -3.20601
Question 3: Plotting
In a normal RGB colour image, there are 3 channels, one each for red, green and blue colour. It is
organised in a 3D array, e.g. an array of size 100 * 120 * 3, for an image that is 100 (vertical) by 120
(horizontal) pixels. Then, X[ , , 1] is an array that represents the red colour component of the image.
Similarly X[ , , 2] is for green and X[ , , 3] for blue.
A hyperspectral image (HSI) has more than three colour components. Each pixel in a HSI is a spectrum: it
represents the brightness of the image in particular wavelength ranges. For example, X[2,3,] is the
spectrum at the second row and the third column of the image. Here we will look at a HSI remotely sensed
by the ROSIS sensor http://www.opairs.aero/rosis_en.html. The whole data set is packed in a matlab file
called paviauni.mat which is attached separately
A). Use the function readMat() in the R package called R.matlab to read imn the matlab file. Save the
contents as a list named A, as follows.
library(R.matlab)
A <- readMat('paviauni.mat')
B). The list A has two enties. A$X is the HSI. A$ groundtruth classifies each pixel into one of 10 classes.
Print the dimensions of A$X and A$groundtruth, as follows.
A$X is 610 by 340 y 103
A$groundtruth is 610 by 340
C) For each of the classifications 0, 1, 2, ... , 9 in A$groundtruth, count how many pixels out of
the total of 610 × 340 = 207400 in the image have that classification.
Class 0: 164624 pixels
Class 1: 6631 pixels
Class 2: 18649 pixels
Class 3: 2099 pixels
Class 4: 3064 pixels
Class 5: 1345 pixels
Class 6: 5029 pixels
Class 7: 1330 pixels
Class 8: 3682 pixels
Class 9: 947 pixels
D) Produce a plot of 25 spectra randomly chosen from classes 1 to 9, plotting each class in separate
subfigure as below. Hint: consider the which() function, including the argument arr.ind.
CS 340 Milestone One Guidelines and Rubric Overview: For this assignment, you will implement the fundamental operations of create, read, update,
Retail Transaction Programming Project Project Requirements: Develop a program to emulate a purchase transaction at a retail store. This
7COM1028 Secure Systems Programming Referral Coursework: Secure
Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip
CS 340 Final Project Guidelines and Rubric Overview The final project will encompass developing a web service using a software stack and impleme