Last data update: 2014.03.03

R: Start / Stop the automatic redirection of output to HTML...
HTMLStartR Documentation

Start / Stop the automatic redirection of output to HTML files

Description

Add the automatic redirection of output to an HTML file. The R session is modified in the following way: a new prompt is proposed (by default HTML>) and each parsed command is also evaluated using HTML generic method, so that the user benefits of both a normal and a HTML output. Please read carefully the details below.

Usage

HTMLStart(outdir = tempdir(), filename = "index", extension = "html",
echo = FALSE, autobrowse = FALSE, HTMLframe = TRUE, withprompt = "HTML> ",
CSSFile = "R2HTML.css", BackGroundColor = "FFFFFF", BackGroundImg = "",
Title = "R output") 
HTMLStop()

Arguments

outdir

physical directory to store the output

filename

name of the target HTML main file

extension

extension of the target HTML file (htm, html,...)

echo

should the parsed commands be written in the output? [boolean]

autobrowse

should the browser be invoked each time a command is issued? [boolean]

HTMLframe

should the output have a HTML frame structure? [boolean]

withprompt

prompt to display while using HTMLStart/HTMLStop

CSSFile

path and name of a CSS file to use

BackGroundColor

option bgcolor for HTML tag <body>

BackGroundImg

option background for HTML tag <body>

Title

string to pass to HTML <title> tag

Details

The user may need to know the following points which describe how R2HTML does work:

- Each parsed command is evaluated and the returned value is passed to the generic function HTML. This evaluation is assured by addTaskCallback function, which is used to add a specific task each time R has to parse an expression.

- A new environment is built, where internal variables such as physical path are stored. This environment is not visible by the user. It is destroyed when calling HTMLStop.

Value

no useful output is returned.

Note

The argument echo is very usefull for teaching purposes.

Author(s)

Eric Lecoutre

See Also

HTML

Examples


# Perform's one's own direct report

dir.create(file.path(tempdir(),"R2HTML"))
HTMLStart(file.path(tempdir(),"R2HTML"),HTMLframe=FALSE, Title="My report",autobrowse=FALSE)
as.title("This is my first title")
x <- 1
y<- 2
x+y
HTMLStop()


## 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()
}

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 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.

> library(R2HTML)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/R2HTML/HTMLStart.Rd_%03d_medium.png", width=480, height=480)
> ### 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"))
> HTMLStart(file.path(tempdir(),"R2HTML"),HTMLframe=FALSE, Title="My report",autobrowse=FALSE)

 *** Output redirected to directory:  /tmp/RtmpQjOUYh/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/RtmpQjOUYh/R2HTML/index.html"
> 
> 
> ## Use for interactive teaching course
> #if (interactive()){
> 	dir.create(file.path(tempdir(),"R2HTML"))
Warning message:
In dir.create(file.path(tempdir(), "R2HTML")) :
  '/tmp/RtmpQjOUYh/R2HTML' already exists
> 	HTMLStart(file.path(tempdir(),"R2HTML"),echo=TRUE)

 *** Output redirected to directory:  /tmp/RtmpQjOUYh/R2HTML
 *** Use HTMLStop() to end redirection.[1] TRUE
HTML> 	as.title("Manipulation vectors")
[1] "Manipulation vectors"
attr(,"class")
[1] "title"
HTML> 	1:10
 [1]  1  2  3  4  5  6  7  8  9 10
HTML> 	sum(1:10)
[1] 55
HTML> 	c(1:10,rep(3,4))
 [1]  1  2  3  4  5  6  7  8  9 10  3  3  3  3
HTML> 	HTMLStop()
[1] "/tmp/RtmpQjOUYh/R2HTML/index_main.html"
> #}
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>