R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i686-pc-linux-gnu (32-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(79,58,60,108,49,0,121,1,20,43,69,78,86,44,104,63,158,102,77,82,115,101,80,50,83,123,73,81,105,47,105,94,44,114,38,107,30,71,84,0,59,33,42,96,106,56,57,59,39,34,76,20,91,115,85,76,8,79,21,30,76,101,94,27,92,123,75,128,105,55,56,41,72,67,75,114,118,77,22,66,69,105,116,88,73,99,62,53,118,30,100,49,24,67,46,57,75,135,68,124,33,98,58,68,81,131,110,37,130,93,118,39,13,74,81,109,151,51,28,40,56,27,37,83,54,27,28,59,133,12,0,106,23,44,71,116,4,62,12,18,14,60,7,98,64,29,32,25,16,48,100,46,45,129,130,136,59,25,32,63,95,14,36,113,47,92,70,19,50,41,91,111,41,120,135,27,87,25,131,45,29,58,4,47,109,7,12,0,37,37,46,15,42,7,54,54,14,16,33,32,21,15,38,22,28,10,31,32,32,43,27,37,20,32,0,5,26,10,27,11,29,25,55,23,5,43,23,34,36,35,0,37,28,16,26,38,23,22,30,16,18,28,32,21,23,29,50,12,21,18,27,41,13,12,21,8,26,27,13,16,2,42,5,37,17,38,37,29,32,35,17,20,7,46,24,40,3,10,37,17,28,19,29,8,10,15,15,28,17) > #'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: survival Loading required package: splines Hmisc library by Frank E Harrell Jr Type library(help='Hmisc'), ?Overview, or ?Hmisc.Overview') to see overall documentation. NOTE:Hmisc no longer redefines [.factor to drop unused levels when subsetting. To get the old behavior of Hmisc type dropUnusedLevels(). Attaching package: 'Hmisc' The following object(s) are masked from 'package:survival': untangle.specials The following object(s) are masked from 'package:base': format.pval, round.POSIXt, trunc.POSIXt, units > m <- mean(x) > e <- median(x) > postscript(file="/var/wessaorg/rcomp/tmp/1xpz81353252894.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/2p0x01353252894.tab") > > try(system("convert tmp/1xpz81353252894.ps tmp/1xpz81353252894.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.783 0.193 2.051