One of the problems in my assignment for class is the following:
Calculate a so-called "trimmed mean" of column 9 of x_mat by trimming off 5 percent of the values from each end of x. Please do not store the result in an object.
I have to be making this harder than it actually is. Here is what I came up with:
From the help file on the mean function (emphasis mine)
trim the fraction (0 to 0.5) of observations to be trimmed from each end of x before the mean is computed. Values of trim outside that range are taken as the nearest endpoint.
The question you presented asks that you "[trim] off 5 percent of values from each end of x". The help file says that the trim argument is " the fraction (0 to 0.5) of observations to be trimmed from each end of x". How much will be trimmed off each end of x_mat[,9] by the code you presented:
mean(x_mat[, 9], trim = 0.1)
I am being somewhat indirect to try to fulfill the spirit of the forum's homework policy.
Ah fair enough. Thanks for the input. It is difficult knowing if the coding is actually doing what you expected when R gives you a result. Rather it just say the input was bad because then at least you know it is wrong!
Then we go ahead and remove 1 element from each end. So we have element 2 to 9 (after ordering). 1 and 3 are removed. We are trimming 1/10=0.1 from each end.