wilcox.test()DescTools, modeest, robustbase
wants <- c("DescTools", "modeest", "robustbase")
has   <- wants %in% rownames(installed.packages())
if(any(!has)) install.packages(wants[!has])age <- c(17, 30, 30, 25, 23, 21)
mean(age)[1] 24.33333weights <- c(0.6, 0.6, 0.3, 0.2, 0.4, 0.6)
weighted.mean(age, weights)[1] 23.7037library(DescTools)
Gmean(age)[1] 23.86509library(DescTools)
Hmean(age)[1] 23.38384vec <- c(11, 22, 22, 33, 33, 33, 33)
library(modeest)
mfv(vec)[1] 33mlv(vec, method="mfv")[1] 33median(age)[1] 24Default: Quartiles
(quant <- quantile(age))   0%   25%   50%   75%  100% 
17.00 21.50 24.00 28.75 30.00 quant[c("25%", "50%")] 25%  50% 
21.5 24.0 Set probabilities with option probs
quantile(age, probs=c(1/3, 2/3))33.33333% 66.66667% 
 22.33333  26.66667 mean(age, trim=0.2)[1] 24.75library(DescTools)
border   <- quantile(age, probs=c(0.2, 0.8))
(ageWins <- Winsorize(age, val=border))[1] 21 30 30 25 23 21mean(ageWins)[1] 25library(robustbase)
hM <- huberM(age)
hM$mu[1] 24.33333library(DescTools)
HodgesLehmann(age, conf.level=0.95)   est lwr.ci upr.ci 
    24     NA     NA N <- 8
X <- rnorm(N, 100, 15)
Y <- rnorm(N, 110, 15)
wilcox.test(X, Y, conf.int=TRUE)$estimatedifference in location 
             -2.536386 try(detach(package:modeest))
try(detach(package:DescTools))
try(detach(package:robustbase))R markdown - markdown - R code - all posts