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(107,101,98,98,96,96,95,91,91,90,90,90,88,87,86,83,82,80,77,77,76,76,75,74,74,72,72,71,71,70,69,68,68,68,68,68,67,66,66,66,65,65,65,64,64,64,63,63,62,62,62,62,61,61,61,60,60,59,59,58,58,57,57,57,56,56,55,55,54,54,54,52,52,51,51,51,51,51,51,50,50,50,50,49,49,49,49,48,48,48,48,48,47,47,47,47,46,46,46,45,44,44,43,43,42,42,42,42,42,42,42,41,41,41,40,40,40,40,39,39,39,39,38,38,38,38,38,38,37,37,37,37,37,37,37,36,36,36,35,35,34,34,34,34,34,33,33,33,33,33,32,32,31,31,30,30,30,29,29,29,29,29,28,28,28,28,28,28,28,28,28,28,28,28,27,27,27,27,27,26,26,26,26,26,25,25,25,25,25,24,24,24,24,24,24,24,24,24,23,23,23,23,23,23,23,22,22,22,22,22,22,22,21,21,21,21,21,21,20,20,20,20,20,20,20,20,19,19,18,18,18,18,18,18,18,17,17,17,17,17,17,17,16,16,16,16,16,16,15,15,15,15,15,14,14,14,14,14,14,13,13,13,12,12,12,12,11,11,11,11,10,10,9,9,9,9,9,9,8,7,6,6,6,5,5,5,4,2,2) > par2 = '0' > par1 = '8' > ylab = 'density' > xlab = 'value of data series' > main = 'Histogram and Fitted Normal Density' > library(MASS) > par1 <- as.numeric(par1) > if (par2 == '0') par2 = 'Sturges' else par2 <- as.numeric(par2) > x <- as.ts(x) #otherwise the fitdistr function does not work properly > r <- fitdistr(x,'normal') > r mean sd 38.3667820 22.8572463 ( 1.3445439) ( 0.9507361) > postscript(file="/var/fisher/rcomp/tmp/1zwbl1355749073.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > myhist<-hist(x,col=par1,breaks=par2,main=main,ylab=ylab,xlab=xlab,freq=F) > curve(1/(r$estimate[2]*sqrt(2*pi))*exp(-1/2*((x-r$estimate[1])/r$estimate[2])^2),min(x),max(x),add=T) > dev.off() null device 1 > > #Note: the /var/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/rcomp/createtable") > > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Parameter',1,TRUE) > a<-table.element(a,'Estimated Value',1,TRUE) > a<-table.element(a,'Standard Deviation',1,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'mean',header=TRUE) > a<-table.element(a,r$estimate[1]) > a<-table.element(a,r$sd[1]) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'standard deviation',header=TRUE) > a<-table.element(a,r$estimate[2]) > a<-table.element(a,r$sd[2]) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/fisher/rcomp/tmp/2x4ns1355749074.tab") > > try(system("convert tmp/1zwbl1355749073.ps tmp/1zwbl1355749073.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.996 0.255 1.228