Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1 his assignment serves as practice for the material we have covered in class an

ID: 3666019 • Letter: 1

Question

1 his assignment serves as practice for the material we have covered in class and in your assigned readings regarding chapters 1 and 2 of the text. Below are several questions to answer by typing the correct syntax directly into the R console (as we have been doing in class). When you have finished, access the File" pull-down menu and select "Save to File to save the entire R console as a text file called "Assignment 1.R" preceded with your first initial and last name: i.e., "SHAYS Assignment 1.bkt". Upload this to Blackboard by 2:00 pm Monday 2/08/2016. No other submission method will be accepted, nor will any late assignments. If you perform the assignment in multiple R sessions, save the console window each time and merge these files as necessary so that only a single text file is submitted. I will run your code and you will be graded on whether the code runs without error, whether the answers are correct, and if proper commenting of your code (use of exists in your file You will find there are numerous different syntax sequences to write code that all arrive at the exact, correct, and same answer as some other method. This is OK, any correct answer receives full credit: whether it took 20 lines to do so or a single function. These distinctions will become talking points for our lectures For the remainder ofthe assignment, comment your code when necessary using the convention. At the very least, use the #comment syntax to indicate which part of which problem is being answered in order to receive full credit 4) For the matrix in problem 3, what is the element in the 2nd row, third column? Set it to a missing value, then find the sumof the rows of this matrix, excluding missing values from the calculation.

Explanation / Answer

I have first created the matrix for 3rd and used that for 4th

>#creating a random vector with mean=5 and sd=2

> x<-rnorm(15,5,2)

>#converting the vector to a 5x3 matrix filling it row wise

>m<-matrix(x,nrow=5,ncol=3,byrow=TRUE)

># displaying the element in 2nd row 3 rd column

>m[2,3]

>#making it missing value

>m[2,3]=NA

># sum of the rows of matrix excluding missing value

>sum<-rowSums(m,na.rm=TRUE)

sum has sum of each row of matrix after removing missing values