What Will Be The Output Of The Following R Codep Pre Langrsplus #358
What will be the output of the following R code?</p> <pre><code class="language-rsplus"> > centre <- function(x, type) { + switch(type, + mean = mean(x), + median = median(x), + trimmed = mean(x, trim = .1)) + } > x <- rcauchy(10) > centre(x, "mean") </code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs110 R Language. It can also be found in gs gs110 Control Structures, Functions, Scoping Rules, Loop Functions and Debugging - Control Structures - Quiz No.3.
What will be the output of the following R code?
> centre <- function(x, type) { + switch(type, + mean = mean(x), + median = median(x), + trimmed = mean(x, trim = .1)) + } > x <- rcauchy(10) > centre(x, "mean")
0.8760325
0.5360891
0.6086504
gives mean with values depending on rcauchy values