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' Write a binary operation %-% that subtracts the second operand from the first, but does not go below 0. print(5 %-% 2) # prints 3 print(5 %-% 12) # prints 0 QUESTION -ext .R -run 'Rscript omsi_answer2.R' R has a "no side effects" philosophy, but one can force side effects if one considers it useful. Here you will write an alternative to sort(), to be named globalSort(), that sorts the argument in-place. globalSort <- function(xname) { } w <- c(5,2,12,11,15) w # prints 5 2 12 11 15 globalSort('w') w # prints 2 5 11 12 15 QUESTION -ext .R -run 'Rscript omsi_answer3.R' Write a function to sort the rows of a data frame, according to a specified column. The latter is specified by either column number of column name. dfsort <- function(df,col) { if (is.numeric(col)) { toSort <- df[ ] } else col <- df[ ] df[ ] } d <- data.frame(x=1:3,y=c(5,2,12)) dfsort(d,2) # output: # x y # 2 2 2 # 1 1 5 # 3 3 12 dfsort(d,'y') # same output