R version 3.2.2 (2015-08-14) -- "Fire Safety" 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(85.13,85.54,85.47,85.78,86.07,86.05,86.32,86.43,86.41,86.38,86.59,86.68,86.87,87.32,87.13,87.42,87.22,87.17,87.52,87.49,87.53,87.93,88.54,88.96,89.3,90.01,90.52,90.64,91.25,91.59,92.09,91.81,92.03,92.15,91.98,92.11,92.28,92.53,91.97,92.05,91.87,91.49,91.48,91.63,91.46,91.61,91.7,91.87,92.21,92.65,92.83,93.02,93.33,93.35,93.45,93.51,93.8,93.94,94.02,94.26,94.71,95.26,95.54,95.69,96.03,96.4,96.55,96.45,96.65,96.84,97.21,97.31,97.91,98.51,98.54,98.52,98.66,98.53,98.71,98.92,98.96,99.25,99.32,99.41,99.36,99.58,99.77,99.77,100.03,100.2,100.24,100.1,100.03,100.18,100.29,100.41,100.6,100.75,100.79,100.44,100.29,100.34,100.46,100.12,100.06,100.28,100.28,100.4) > #'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/1bd4g1444475350.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/2j28c1444475350.tab") > > try(system("convert tmp/1bd4g1444475350.ps tmp/1bd4g1444475350.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.092 0.132 1.220