這一章我感覺整體比較難
課后練習有兩題不會
medAndmea <- function(x,funs){
if(length(x) == 0) {stop("There is a missing")
}else{
funs <- match.arg(funs,choices = c("mea","med"))
switch (funs,
"mea" = mean(x),
"med" = median(x))
}
}
x <- c(1,4,3)
medAndmea(x,"mea")