R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree" Copyright (C) 2015 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > x <- c(81.83,82.58,82.6,82.71,82.98,83.11,83.22,83.32,83.39,83.45,83.52,83.59,83.97,84.48,84.8,84.93,85.14,85.22,85.54,85.5,85.61,85.75,85.89,85.94,86.08,86.3,86.97,87.3,87.62,87.59,87.78,87.87,88.17,88.67,88.84,88.9,88.98,89.27,89.69,89.72,89.79,89.82,89.98,90.09,90.31,90.3,90.48,90.52,90.53,91.38,91.87,91.9,92.08,92.14,92.09,92.32,92.67,92.78,92.96,93.12,93.32,94.12,94.34,94.52,94.81,94.95,94.99,95.03,95.16,95.41,95.46,95.62,95.66,95.96,96.18,96.24,97.03,97.11,97.28,97.74,97.83,98.14,98.18,98.21,98.43,98.67,99.51,99.64,99.83,99.84,99.94,100.17,100.56,101.05,101.17,101.21,101.01,101.92,102.33,102.41,102.5,102.69,102.98,103.11,103.36,103.8,104.07,104.15,104.19,104.64,104.98,105.25,105.43,105.59,105.84,105.87,106,106.14,106.24,106.31) > #'GNU S' R Code compiled by R2WASP v. 1.2.291 () > #Author: root > #To cite this work: Wessa P., (2012), Mean versus Median (v1.0.2) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_meanversusmedian.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > # > library(Hmisc) Loading required package: grid Loading required package: lattice Loading required package: survival Loading required package: Formula Loading required package: ggplot2 Attaching package: 'Hmisc' The following objects are masked from 'package:base': format.pval, round.POSIXt, trunc.POSIXt, units > m <- mean(x) > e <- median(x) > postscript(file="/var/wessaorg/rcomp/tmp/128qz1457023568.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > op <- par(mfrow=c(2,1)) > mydensity1 <- density(x,kernel='gaussian',na.rm=TRUE) > plot(mydensity1,main='Density Plot - Gaussian Kernel',xlab='Median (0 -> full line) | Mean (0 -> dashed line)',ylab='density') > abline(v=e,lty=1) > abline(v=m,lty=5) > grid() > myseq <- seq(0.01, 0.99, 0.01) > hd <- hdquantile(x, probs = myseq, se = TRUE, na.rm = FALSE, names = TRUE, weights=FALSE) > plot(myseq,hd,col=2,main='Harrell-Davis Quantiles',xlab='quantiles',ylab='Median (0 -> full) | Mean (0 -> dashed)') > abline(h=m,lty=5) > abline(h=e,lty=1) > grid() > par(op) > dev.off() null device 1 > > #Note: the /var/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/rcomp/createtable") > > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Median versus Mean',2,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'mean',header=TRUE) > a<-table.element(a,mean(x)) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'median',header=TRUE) > a<-table.element(a,median(x)) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/2pfq71457023568.tab") > > try(system("convert tmp/128qz1457023568.ps tmp/128qz1457023568.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.188 0.152 1.338