The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 356 Weeks Ago, 5 Days Ago |
| Questions Answered: | 20103 |
| Tutorials Posted: | 20155 |
MBA, PHD
Phoniex
Jul-2007 - Jun-2012
Corportae Manager
ChevronTexaco Corporation
Feb-2009 - Nov-2016
Question description
Â
Â
Write a function calledlowerTrimthat takes 2 arguments:xandtrimBelow. This function takes the average of those values inxthat are greater than thetrimBelow. Makexa required argument and supply a default value fortrimBelowof negative infinity.
First create some variable to be used for testing later.
x = 1:5
y = letters
z = list(a = 1:5, b = 1:10)
Now test your function with the following
lowerTrim(x)
lowerTrim(-10:5, trimBelow = 0)
lowerTrim(-10:5, -2)
lowerTrim(x = -10:5, trimBelow = Inf)
The return values should be: 3, 3, 2, and NaN, respectively
q2
Â
Q2. Extend your function so that it takes a third parameter, which allows the caller to use a function other thanmean()when calculating thelowerTrim. Call this argumentsumFuncand give it a default value so that it operates like the originallowerTrimfunction. Call this revised functionlowerTrim2
Check your function with the following calls:
lowerTrim2(-10:20, trimBelow = -5, median)
lowerTrim2(-10:20, trimBelow = 0, sumFunc = summary)
The return values should be 8 and the summary values of 1, 5.75 10.5, 10.5, 15.2, and 20.
Hel-----------lo -----------Sir-----------/Ma-----------dam----------- T-----------han-----------k Y-----------ou -----------for----------- us-----------ing----------- ou-----------r w-----------ebs-----------ite----------- an-----------d a-----------cqu-----------isi-----------tio-----------n o-----------f m-----------y p-----------ost-----------ed -----------sol-----------uti-----------on.----------- Pl-----------eas-----------e p-----------ing----------- me----------- on----------- ch-----------at -----------I a-----------m o-----------nli-----------ne -----------or -----------inb-----------ox -----------me -----------a m-----------ess-----------age----------- I -----------wil-----------l