Last data update: 2014.03.03

R: Insert a graph in a HTML report
HTMLInsertGraphR Documentation

Insert a graph in a HTML report

Description

Write the HTML <img> tag to an output, so that a existant graph could be displayed in the HTML report

Usage

HTMLInsertGraph(GraphFileName="", Caption="", GraphBorder=1,
Align="center", WidthHTML=500, HeightHTML=NULL,
file=HTMLGetFile(), append=TRUE,...)

Arguments

GraphFileName

Name of the target graph (GIF, JPEG or PNG)

Caption

If non empty, text to be written under the graph, as its caption

GraphBorder

Size of the border, in pixels

Align

Alignment of the graph (center, left or right)

WidthHTML

Width of the image in HTML

HeightHTML

Height of the image in HTML (NULL for not specified)

file

Name of the target HTML file (the report)

append

logical. If 'TRUE' output will be appended to 'file'; otherwise, it will overwrite the contents of 'file'

...

...

Details

The steps to add a graph to a HTML file are the following: first create the graph, by using a device convenient for web pages, such as GIF, JPEG or PNG. Ensure to write it in the same directory than the HTML file. Then call HTMLInsertGraph.

Value

no value returned.

Author(s)

Eric Lecoutre

See Also

HTMLplot

Examples


	directory=getwd()
	HTMLoutput=file.path(directory,"output.html")
	graph1="graph1.png"
	# Write graph to a file
	## Not run: png(file.path(directory,graph1))
	## Not run: plot(table(rpois(100,5)), type = "h", col = "red", lwd=10,main="rpois(100,lambda=5)")
	## Not run: dev.off()
	# Insert graph to the HTML output
	HTMLInsertGraph(graph1,file=HTMLoutput,caption="Sample discrete distribution plot")

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/HTMLInsertGraph.Rd_%03d_medium.png", width=480, height=480)
> ### 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
> 	## Not run: png(file.path(directory,graph1))
> 	## Not run: plot(table(rpois(100,5)), type = "h", col = "red", lwd=10,main="rpois(100,lambda=5)")
> 	## Not run: dev.off()
> 	# Insert graph to the HTML output
> 	HTMLInsertGraph(graph1,file=HTMLoutput,caption="Sample discrete distribution plot")
[1] TRUE
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>