Читать книгу The Big R-Book - Philippe J. S. De Brouwer - Страница 272
8.1.2 The Median
Оглавлениеmedian
While the mean (and the average in particular) is widely used, it is actually quite vulnerable to outliers. It would therefore, make sense to have a measure that is less influenced by the outliers and rather answers the question: what would a typical observation look like. The median is such measure.
central tendency – median
The median is the middle-value so that 50% of the observations are lower and 50% are higher.
x <- c(1:5,5e10,NA) x ## [1] 1e+00 2e+00 3e+00 4e+00 5e+00 5e+10 NA median(x) # no meaningful result with NAs ## [1] NA median(x,na.rm = TRUE) # ignore the NA ## [1] 3.5 # Note how the median is not impacted by the outlier, # but the outlier dominates the mean: mean(x, na.rm = TRUE) ## [1] 8333333336