DESCRIPTION Students: Please keep in mind the OMSI rules. Save your files often, make sure OMSI fills your entire screen at all times, etc. Remember that clicking CopyQtoA will copy the entire question box to the answer box. In questions involving code which will PARTIALLY be given to you in the question specs, you may need add new lines. There may not be information given as to where the lines should be inserted. If a question includes test code, make sure to include it in your submission Do not answer any question with simulation code unless this is specified. MAKE SURE TO RUN THE CODE IN PROBLEMS INVOLVING CODE! Hit the OMSI Submit and Run button. QUESTION -ext .R -run 'Rscript omsi_answer1.R' (Code answer.) Here you will develop an S3 class 'string' that acts like Python character tuples. s1 <- list(s='abc') class(s1) <- 'string' # add code here s2 <- list(s='de') class(s2) <- 'string' length(s2) # 2 s3 <- 'f' s1+s2+s3 # "abcdef" s1+s2+'uv'+s3 # "abcdeuvf" s1+'uv'+s2 # "abcuvde" Note: It was noted in class that even addition in X is a function, "+'(), Note the quotation marks. If we have such a function for a class 'x', the function is referred to as '+.x'(). QUESTION -ext .R -run 'Rscript omsi_answer2.R' (Code answer.) In the example in Sec. 13.6 in our book, a major problem was noted. If the shorter curve were to be plotted first, the taller one will be cut off at the top. Write a function that deals with this, by checking which curve is taller before plotting. Hint: Look at the online help for 'density'. plot2densities <- function(x1,x2) { } # 'faithful' is a built-in R dataset; check via ?faithful a <- faithful$eruptions b <- faithful$waiting / 20 plot2densities(a,b) # plots correctly plot2densities(b,a) # plots correctly