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(250.71,251.57,260.85,265.47,262.37,272.39,277.49,274.41,274.42,267.1,258.84,253.97,253.88,253.3,249.86,246,248.42,250.29,246.9,255.2,253.33,251.02,254.5,253.18,256.03,262.15,259.94,253.75,247.69,242.42,231.82,235.88,240.68,260.15,265.32,265.02,279.86,298.3,304.14,295.26,281.93,280.46,272.06,270.05,271.84,268.49,270.92,273.22,269.43,271.21,265.4,265.53,276.78,281.49,283.75,281.45,282.1,274.01,275.51,277.62,275.33,271.15,270.89,265.29,266.96,266.87,267.68,272.37,285.05,296.79,309.15,304.19,307.33,290.68,292.26,294.81,293.67,293.57,286.28,278.93,284.22,282.09,282.26,285.79,294.01,292.73,303.01,298.67,292.38,295.7,294.9,299.46,299.75,294.76,297.68,300.24,302.48,310.2,311.49,307.37,304.58,305.87,309.81,313.91,313.2,307.85,306.89,310.83) > #'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/12vtn1444319014.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/2eznl1444319014.tab") > > try(system("convert tmp/12vtn1444319014.ps tmp/12vtn1444319014.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.112 0.139 1.248