R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 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 a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("R2HTML-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('R2HTML') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "HTML" > > ### * HTML > > flush(stderr()); flush(stdout()) > > ### Name: HTML > ### Title: Outputs an object to a HTML file > ### Aliases: HTML HTML.anova HTML.aov HTML.aovlist HTML.array HTML.atomic > ### HTML.by HTML.call HTML.character HTML.coefmat HTML.complex > ### HTML.connection HTML.default HTML.density HTML.difftime > ### HTML.dummy.coef HTML.dummy.coef.list HTML.environment HTML.factor > ### HTML.family HTML.formula HTML.ftable HTML.glm HTML.glm.null > ### HTML.hsearch HTML.htest HTML.infl HTML.integer HTML.integrate > ### HTML.list HTML.listof HTML.lm HTML.lm.null HTML.logical HTML.logLik > ### HTML.MethodsFunction HTML.mtable HTML.noquote HTML.numeric > ### HTML.octmode HTML.ordered HTML.pairlist HTML.POSIXct HTML.POSIXlt > ### HTML.rle HTML.SavedPlots HTML.simple.list HTML.socket > ### HTML.summary.aov HTML.summary.aovlist HTML.summary.glm > ### HTML.summary.glm.null HTML.summary.lm HTML.summary.lm.null > ### HTML.summary.manova HTML.summary.table HTML.table HTML.tables.aov > ### HTML.terms HTML.ts HTML.TukeyHSD HTML.xtable HTML.xtabs HTML.abbrev > ### HTML.agnes HTML.Anova HTML.anova.loglm HTML.ar HTML.Arima HTML.arima0 > ### HTML.boot HTML.bootci HTML.bSpline HTML.clara HTML.correspondence > ### HTML.cox.zph HTML.coxph.null HTML.date HTML.diana HTML.dissimilarity > ### HTML.dist HTML.ecdf HTML.ellipsoid HTML.factanal HTML.fanny > ### HTML.fitdistr HTML.fractions HTML.gam HTML.gamma.shape HTML.glm.dose > ### HTML.grob HTML.hclust HTML.HoltWinters HTML.lda HTML.libraryIQR > ### HTML.loadings HTML.loess HTML.loglm HTML.lqs HTML.mca HTML.medpolish > ### HTML.mona HTML.multinom HTML.nls HTML.nnet HTML.pairwise.htest > ### HTML.pam HTML.polr HTML.polySpline HTML.power.htest HTML.ppolySpline > ### HTML.ppr HTML.prcomp HTML.princomp HTML.qda HTML.ridgelm HTML.rlm > ### HTML.rms.curv HTML.rpart HTML.saddle.distn HTML.shingle > ### HTML.shingleLevel HTML.simplex HTML.smooth.spline HTML.stepfun > ### HTML.stl HTML.StructTS HTML.structure HTML.summary.agnes > ### HTML.summary.clara HTML.summary.diana HTML.summary.fanny > ### HTML.summary.gam HTML.summary.loess HTML.summary.loglm > ### HTML.summary.mona HTML.summary.multinom HTML.summary.negbin > ### HTML.summary.nls HTML.summary.nnet HTML.summary.pam HTML.summary.polr > ### HTML.summary.ppr HTML.summary.prcomp HTML.summary.princomp > ### HTML.summary.rlm HTML.tskernel HTML.tukeyline HTML.tukeysmooth > ### HTML.unit HTML.viewport HTML.reStruct HTML.summary.lme > ### HTML.summary.pdDiag > ### Keywords: print IO file > > ### ** Examples > > dir.create(file.path(tempdir(),"R2HTML")) > target <- HTMLInitFile(file.path(tempdir(),"R2HTML"),filename="sample", BackGroundColor="#BBBBEE") > HTML("
Don't forget to use the CSS file in order to benefit from fixed size police",file=target) > tmp <- as.data.frame(matrix(rnorm(100),ncol=10)) > HTML(tmp,file=target) > HTMLEndFile() > > > > cleanEx(); ..nameEx <- "HTML.cormat" > > ### * HTML.cormat > > flush(stderr()); flush(stdout()) > > ### Name: HTML.cormat > ### Title: Write a correlation matrix with HTML formatting > ### Aliases: HTML.cormat > ### Keywords: IO multivariate > > ### ** Examples > > tmpfic=HTMLInitFile(tempdir(),CSSFile="http://www.stat.ucl.ac.be/R2HTML/Pastel.css") > data(iris) > HTML(as.title("Fisher Iris dataset / Correlation matrix - normal matrix"),file=tmpfic) > HTML(cor(iris[,1:4]), file=tmpfic) > HTML(as.title("Fisher Iris dataset / Correlation matrix - traffic highlighting"),file=tmpfic) > HTML.cormat(cor(iris[,1:4]), file=tmpfic) Sepal.Length Sepal.Width Petal.Length Petal.Width Sepal.Length 1.00 -0.12 0.87 0.82 Sepal.Width -0.12 1.00 -0.43 -0.37 Petal.Length 0.87 -0.43 1.00 0.96 Petal.Width 0.82 -0.37 0.96 1.00 > > # File is generated, you can call the browser: > ## Not run: browseURL(tmpfic) > > > > > cleanEx(); ..nameEx <- "HTML.data.frame" > > ### * HTML.data.frame > > flush(stderr()); flush(stdout()) > > ### Name: HTML.data.frame > ### Title: Write a data.frame (or matrix) to a HTML output > ### Aliases: HTML.data.frame HTML.matrix > ### Keywords: datasets IO > > ### ** Examples > > tmpfic=HTMLInitFile(tempdir(),CSSFile="http://www.stat.ucl.ac.be/R2HTML/R2HTML.css") > data(iris) > HTML(as.title("Fisher Iris dataset"),file=tmpfic) > HTML(iris, file=tmpfic) > # File is generated, you can call the browser: > ## Not run: browseURL(tmpfic) > > # Export one line of iris using default decimal separator > HTML(iris[1,],file="")

  Sepal.Length Sepal.Width Petal.Length Petal.Width Species
15.13.51.40.2setosa

> > # Seeing default decimal separator: > getOption("R2HTML.format.decimal.mark") [1] "." > > # Modifying it: > options("R2HTML.format.decimal.mark"=",") > HTML(iris[1,],file="")

  Sepal.Length Sepal.Width Petal.Length Petal.Width Species
15,13,51,40,2setosa

> > # Bypassing value set in option: > HTML(iris[1,],file="",decimal.mark="*")

  Sepal.Length Sepal.Width Petal.Length Petal.Width Species
15*13*51*40*2setosa

> > # Using a vector for formatting options > HTML(iris[1:2,1:2],nsmall=c(3,1),file="")

  Sepal.Length Sepal.Width
15,1003,500
24,9003,000

> > > > cleanEx(); ..nameEx <- "HTML.function" > > ### * HTML.function > > flush(stderr()); flush(stdout()) > > ### Name: HTML.function > ### Title: Writes the code of a function to a target HTML file > ### Aliases: HTML.function > ### Keywords: print IO file > > ### ** Examples > > > ## Define a function and export it's code to the file /test.html. > ## Target file may be changed when submitting this code... > > myfile <- paste(tempfile(),".html",sep="") > myfun <- function(x){ + cat("\n Euclidian norm") + return(sqrt(sum(x^2))) + } > HTML(myfun,file=myfile) > cat("\n Test output written in: ",myfile) Test output written in: /tmp/RtmpI1U9uH/file10d63af1.html> > > > > cleanEx(); ..nameEx <- "HTML.latex" > > ### * HTML.latex > > flush(stderr()); flush(stdout()) > > ### Name: HTML.latex > ### Title: Insert a piece of LaTeX into a HTML file > ### Aliases: HTML.latex as.latex > ### Keywords: print IO file > > ### ** Examples > > fic = HTMLInitFile() > HTML.title("sample page",1,file=fic) > HTML("First paragraph",file=fic) > cat("Some text and then an equation:",file=fic,append=TRUE) > HTML(as.latex("\int_{-\infty}^{1}f(x)dx") ,file=fic) > cat(". Nice isn't it?",file=fic,append=TRUE) > HTML(as.latex("\int_{-\infty}^{1}f(x)dx",inline=FALSE) ,file=fic) > HTML(as.latex("\int_{-\infty}^{1}f(x)dx",inline=FALSE,count=TRUE) ,file=fic) > HTML(as.latex("\int_{-\infty}^{1}f(x)dx",inline=FALSE,label="My equation") ,file=fic) > cat("file:", fic, "is created") file: /tmp/RtmpI1U9uH/index.html is created> > ## Not run: browseURL(fic) > > > > cleanEx(); ..nameEx <- "HTML.title" > > ### * HTML.title > > flush(stderr()); flush(stdout()) > > ### Name: HTML.title > ### Title: Writes a title in a target HTML output > ### Aliases: HTML.title as.title > ### Keywords: print IO file > > ### ** Examples > > ## Write a title in the file /test.html. > ## Target file may be changed when submitting this code... > > myfile <- paste(tempfile(),".html",sep="") > > tit1 <- as.title("This is method 1") > > HTML(tit1, file=myfile) > > HTML.title("This is method 2",file=myfile, HR=3) > cat("\n Test output written in: ",myfile) Test output written in: /tmp/RtmpI1U9uH/file60b7acd9.html> > > > > cleanEx(); ..nameEx <- "HTMLCSS" > > ### * HTMLCSS > > flush(stderr()); flush(stdout()) > > ### Name: HTMLCSS > ### Title: Insert HTML code to refer to an external CSS file > ### Aliases: HTMLCSS > ### Keywords: print IO file > > ### ** Examples > > myfile <- file.path(tempdir(),"tmp.html") > HTMLCSS(myfile,CSSfile="myownCSS.CSS") > > > > cleanEx(); ..nameEx <- "HTMLChangeCSS" > > ### * HTMLChangeCSS > > flush(stderr()); flush(stdout()) > > ### Name: HTMLChangeCSS > ### Title: Change the current CSS file for dynamic use of package > ### Aliases: HTMLChangeCSS > ### Keywords: IO file > > ### ** Examples > > ## Not run: > ##D HTMLStart() > ##D (x=diag(3)) > ##D HTMLChangeCSS("Pastel") > ##D # refresh the browser > ## End(Not run) > > > > cleanEx(); ..nameEx <- "HTMLInitFile" > > ### * HTMLInitFile > > flush(stderr()); flush(stdout()) > > ### Name: HTMLInitFile > ### Title: Begins / Ends a new HTML report output > ### Aliases: HTMLInitFile HTMLEndFile > ### Keywords: print IO file > > ### ** Examples > > # Store in target the name of a output file > dir.create(file.path(tempdir(),"R2HTML")) Warning: '/tmp/RtmpI1U9uH/R2HTML' already exists > target <- HTMLInitFile(file.path(tempdir(),"R2HTML"),"index", BackGroundColor="#BBBBEE") > # Use target to write a dataframe > HTML(as.title("Here is the data frame"),file=target) > HTML("
Don't forget to use the CSS file in order to benefit from fixed size police",file=target) > tmp <- as.data.frame(matrix(rnorm(100),ncol=10)) > HTML(tmp,file=target) > HTMLEndFile() > > > > cleanEx(); ..nameEx <- "HTMLInsertGraph" > > ### * HTMLInsertGraph > > flush(stderr()); flush(stdout()) > > ### Name: HTMLInsertGraph > ### Title: Insert a graph in a HTML report > ### Aliases: HTMLInsertGraph > ### Keywords: print IO file > > ### ** Examples > > > directory=getwd() > HTMLoutput=file.path(directory,"output.html") > graph1="graph1.png" > # Write graph to a file > png(file.path(directory,graph1)) > plot(table(rpois(100,5)), type = "h", col = "red", lwd=10,main="rpois(100,lambda=5)") > dev.off() postscript 2 > # Insert graph to the HTML output > HTMLInsertGraph(graph1,file=HTMLoutput,caption="Sample discrete distribution plot") [1] TRUE > > > > cleanEx(); ..nameEx <- "HTMLStart" > > ### * HTMLStart > > flush(stderr()); flush(stdout()) > > ### Name: HTMLStart > ### Title: Start / Stop the automatic redirection of output to HTML files > ### Aliases: HTMLStart HTMLStop > ### Keywords: print IO file > > ### ** Examples > > > # Perform's one's own direct report > > dir.create(file.path(tempdir(),"R2HTML")) Warning: '/tmp/RtmpI1U9uH/R2HTML' already exists > HTMLStart(file.path(tempdir(),"R2HTML"),HTMLframe=FALSE, Title="My report",autobrowse=FALSE) *** Output redirected to directory: /tmp/RtmpI1U9uH/R2HTML *** Use HTMLStop() to end redirection.[1] TRUE HTML> as.title("This is my first title") [1] "This is my first title" attr(,"class") [1] "title" HTML> x <- 1 HTML> y<- 2 HTML> x+y [1] 3 HTML> HTMLStop() [1] "/tmp/RtmpI1U9uH/R2HTML/index.html" > > ## Use for interactive teaching course > if (interactive()){ + dir.create(file.path(tempdir(),"R2HTML")) + HTMLStart(file.path(tempdir(),"R2HTML"),echo=TRUE) + as.title("Manipulation vectors") + 1:10 + sum(1:10) + c(1:10,rep(3,4)) + HTMLStop() + } > > > > cleanEx(); ..nameEx <- "HTMLbr" > > ### * HTMLbr > > flush(stderr()); flush(stdout()) > > ### Name: HTMLbr > ### Title: Facility functions to write HTML code > ### Aliases: HTMLbr HTMLhr HTMLli > ### Keywords: print IO file > > ### ** Examples > > > ## Insert a line to a HTML file > ## Change the path/name of the file to redirect to your test file > > myfile <- paste(tempfile(),".html",sep="") > HTMLhr(file=myfile) > cat("\n Test output written in: ",myfile) Test output written in: /tmp/RtmpI1U9uH/file3ab50c2a.html> > > > > cleanEx(); ..nameEx <- "HTMLgrid" > > ### * HTMLgrid > > flush(stderr()); flush(stdout()) > > ### Name: HTMLgrid > ### Title: Creates a HTML grid using ActiveWidget grid - > ### www.activewidgets.com > ### Aliases: HTMLgrid HTMLgrid_inline HTMLgrid_references HTMLgrid_summary > ### Keywords: datasets IO > > ### ** Examples > > data(iris) > fic <- HTMLInitFile(useGrid=TRUE,useLaTeX=FALSE) > fic <- HTMLgrid_inline(iris,file=fic) > cat("\n Browse file 'fic':",fic) Browse file 'fic': /tmp/RtmpI1U9uH/index.html> ## Not run: browseURL(fic) > > > > cleanEx(); ..nameEx <- "HTMLplot" > > ### * HTMLplot > > flush(stderr()); flush(stdout()) > > ### Name: HTMLplot > ### Title: Insert a graphic into an HTML output > ### Aliases: HTMLplot > ### Keywords: print IO file > > ### ** Examples > > > ## Plots a graphic and insert it into the file /test.html. > ## Target file and also graph directory should be changed when submitting this code... > > myfile <- paste(tempfile(),".html",sep="") > plot(sin, -pi, 2*pi,main="Sinus") > # HTMLplot(file=myfile,GraphDirectory="/",Caption="Look at this curve!") > > > > cleanEx(); ..nameEx <- "HTMLstem" > > ### * HTMLstem > > flush(stderr()); flush(stdout()) > > ### Name: HTMLstem > ### Title: Insert a stem-and-leaf plot in the HTML output > ### Aliases: HTMLstem > ### Keywords: IO univar > > ### ** Examples > > data(islands) > tmpfic=paste(tempfile(),"html",sep=".") > HTMLstem(log10(islands),tmpfic) > cat("\n stem-and-leaf writen to:", tmpfic,"\n") stem-and-leaf writen to: /tmp/RtmpI1U9uH/file56f32f43.html > > > > cleanEx(); ..nameEx <- "R2HTML-internal" > > ### * R2HTML-internal > > flush(stderr()); flush(stdout()) > > ### Name: HTLMReplaceNA > ### Title: Internal R2HTML functions > ### Aliases: HTMLReplaceNA HTMLCommand HTMLcode > ### Keywords: misc > > ### ** Examples > > > > > > cleanEx(); ..nameEx <- "RweaveHTML" > > ### * RweaveHTML > > flush(stderr()); flush(stdout()) > > ### Name: RweaveHTML > ### Title: A driver to parse HTML noweb files with Sweave tool > ### Aliases: RweaveHTML RweaveHTMLOptions RweaveHTMLFinish > ### RweaveHTMLWritedoc RweaveHTMLSetup RweaveHTMLRuncode SweaveSyntaxHTML > ### Keywords: IO file > > ### ** Examples > > > ## Not run: > ##D library(tools) > ##D Sweave("file.snw",driver=RweaveHTML) > ## End(Not run) > > > > ### *