.trim_mean = function(x, percent) {
x = x[!is.na(x)]
n = length(x)
k = n*(percent/100)/2
# round down if k is half an integer
if(round(k) != k & round(k*2) == k*2) {
lo = floor(k) + 1
hi = n - lo + 1
} else {
lo = round(k) + 1
hi = n - lo + 1
}
x = sort(x)[lo:hi]
return(mean(x))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.