R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-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. > > RC.capture <- function (expression, collapse = NULL) { + resultConn <- textConnection('RC.resultText', open = 'w', local=TRUE) + sink(resultConn) + on.exit(function() { + sink() + close(resultConn) + }) + expression + on.exit(NULL) + sink() + close(resultConn) + return(paste(c(RC.resultText, ''), collapse = collapse, sep = '')) + } > RC.texteval <- function (sourceText, collapse = NULL, echo = TRUE) { + sourceConn <- textConnection(sourceText, open = 'r') + on.exit(close(sourceConn)) + result <- RC.capture(source(file = sourceConn, local = FALSE, echo = echo, print.eval = TRUE), collapse = collapse) + on.exit(NULL) + close(sourceConn) + res <- '' + for(i in 1:length(result)) { + if (result[i]!='') res <- paste(res,result[i],' + ',sep='') + } + return(res) + } > x <- c(83,79,92,83,92,103,82,86,106,79,86,76,108,82,108,118,127,123,72,105,63,86,58,59,100,100,78,94,105,89,101,92,105,76,80,66,117,94,107,110,110,106,94,71,101,84,89,119,97,82,89,70,101,81,74,107,97,83,95,82,88,74,104,73,73,81,79,83,111,138,81,107,66,81,74,96,86,69,73,71,64,79,60,111,107,90,98,77,93,68,74,70,80,81,72,81,92,81) > par3 = '1e-08' > par2 = '80' > par1 = '1' > par1 <- as.numeric(par1) > par2 <- as.numeric(par2) > par3 <- as.numeric(par3) > stem(x,par1,par2,par3) The decimal point is 1 digit(s) to the right of the | 5 | 89 6 | 0346689 7 | 001122333444466789999 8 | 00111111122223333466668999 9 | 02222344456778 10 | 001113455566777788 11 | 0011789 12 | 37 13 | 8 > > #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,'Stem-and-leaf Plot',1,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,paste('
',RC.texteval('stem(x,par1,par2,par3)'),'
',sep='')) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/1bvkl1322563782.tab") > > > > proc.time() user system elapsed 0.202 0.030 0.225