Homework Problem Set 1, Due Friday September 4, 2009. ---------------------------------------------------- (a) Give the R code lines to create an integer vector in your R workspace named W1 of length 240 with first 120 elements consisting of 5,8,2,5,8,2,... and last 120 elements consisting of 1,4,2,0,1,4,2,0,... (b) Give the R code lines to create a real numeric vector in your R workspace named W2 of length 240 consisting of the values cos(x/7) for odd values x , and 1/sqrt(1+0.3*x^2) for even values of x , where the index x = 1,2,... 240. (c) Give the R code lines to create a boolean vector W3 of length 240 which has value "True" at every index x=1,..,240 where W1 is 4 or 8, and has value "False" at every other index. (d) Give the R code lines to create a character vector W4 of labels "A", "B", "C" where "A" appears at every index where the W3 value is "False", and "B" appears at every index where W3 is "True" and W2 is less than .17, and "C" appears at all other indices. (e) Give the R code lines to create a matrix defined by binding together the vectors W1, W2, W3, W4 with column names "Seq", "Num", "TVal", and "Class" respectively. What is the "class" -- i.e., data-type -- of your matrix ? What is the class of columns 2 and 3 of the matrix ? (f) Give the R code lines to create a data-frame out of the same columns W1, W2, W3, W4 and with the same new column names as in (e). But in this part, make sure that columns 1 and 2 of the resulting data-frame remain numeric, column 3 remains boolean, while column 4 is of "character" type. (g) Finally, define and print out in the form of a single labelled table or matrix lines 1,4,6,10,11,20,30,100,119 of the data-frame you created in (f). YOU ARE RESPONSIBLE FOR CHECKING THAT THE R CODE YOU HAND IN FOR PARTS (a)--(f) DOES EXACTLY WHAT IT IS SUPPOSED TO, BUT DO NOT HAND IN THE PRINTED-OUT FORMS OF ALL OF THE VECTORS AND MATRIX AND COMPLETE DATA-FRAME YOU CREATE ! YOU MAY IF YOU LIKE HAND IN SOME INTERMEDIATE RESULTS, PERHAPS (A SMALL) PART OF THE VECTORS, MATRICES, OR DATA-FRAMES YOU CREATE TO DOCUMENT THAT YOU HAVE CODED YOUR COMMANDS CORRECTLY. BUT KEEP THIS PART ALSO AS BRIEF AS POSSIBLE: EACH EXTRA ITEM YOU INCLUDE SHOULD HAVE A SPECIFIC JUSTIFICATION AND INTERPRETATION AS A CHECK ON YOUR WORK ! PLEASE INCLUDE SOME WORDS ### IN COMMENT LINES LIKE THIS WITHIN THE CHECKING PORTIONS OF YOUR HANDED-IN PAPER TO EXPLAIN WHAT YOU ARE DOING.