R: creates a basic HTML page displaying plots and annota
BasicHTML
R Documentation
creates a basic HTML page displaying plots and annota
Description
Creates a basic HTML page displaying plots and annotations that can easily be navigated. The plots can be created either 'on the fly' by passing the appropriate commands or beforehand in which case just the filenames need to be passed.
list of commands that generates the plots. If missing, the graphfiles are assumed to exist already.
HTMLobjects
list of graph filenames, either to be created by the list of commands or to be copied to the Figures subdirectory and/or dataframes to be displayed in sortable tables.
Captions
vector of captions; these go directly below the graphs
MenuLabels
vector of labels for the main page.
Comments
Text/comments to be written between the graphs
file
file name of main page; '.html' extension will be added. The '_main' and '_menu' pages use this base as well.
title
title to be written in the navigation/menu page
width
width for all graphfiles
height
height for all graphfiles
FRAMES
is this an HTML page with frames ?
JSCPATH
path that should contain the jsc components. If non existing, user will be prompted for installation.
LaunchPage
launch the page ?
APPEND
append to existing HTML page ?
href
links to other HTML pages
verbose
level of verbosity
Value
no return value
Author(s)
"Markus Loecher, Berlin School of Economics and Law (BSEL)" <markus.loecher@gmail.com>
See Also
FramedHTML
Examples
if (interactive()){
owd=setwd(tempdir())
BasicHTML(cmds = list("plot(rnorm(100));","plot(1:10);"),
HTMLobjects = list("Fig1.png", "Fig2.png"),
Captions=c("Gaussian noise","seq 1:10"),
MenuLabels = c("Marvel at the graph below","scatterplots are nice"),
title="Test Page",width=480, height=480, verbose=1, JSCPATH = NULL)
#example with plots and graphfiles having been generated beforehand:
png("Fig1.png");
plot(rnorm(100));
dev.off()
png("Fig2.png");
plot(1:10);
dev.off();
BasicHTML( HTMLobjects = list("Fig1.png", "Fig2.png"),
Captions=c("Gaussian noise","seq 1:10"),
MenuLabels = c("Marvel at the graph below","scatterplots are nice"),
title="Test Page",
width=480, height=480, verbose=1, JSCPATH = NULL);
#example with absolute paths for graphfiles :
Fig1 <- paste(tempdir(),"/Fig1.png",sep="")
png(Fig1);
plot(rnorm(100));
dev.off()
Fig2 <- paste(tempdir(),"/Fig2.png",sep="")
png(Fig2);
plot(1:10);
dev.off();
BasicHTML( HTMLobjects = list(Fig1, Fig2),
Captions=c("Gaussian noise","seq 1:10"),
MenuLabels = c("Marvel at the graph below","scatterplots are nice"), title="Test Page",
width=480, height=480, verbose=1, JSCPATH = NULL);
#cleanup:
#system(paste("rm ", Fig1));system(paste("rm ", Fig2))
#example with sorted table:
x <- cbind.data.frame(x1 = round(rnorm(10),3), x2 = round(runif(10),3));
attr(x, "HEADER") <- "some random numbers";
BasicHTML(HTMLobjects = list("Fig1.png", x, "Fig2.png"),
Captions=c("Gaussian noise","Gaussian and uniform random numbers", "seq 1:10"),
file = paste(Sys.getenv("HOME"), "/public_html/tmp/tmp.html",sep=""),
JSCPATH = "../jsc");
setwd(owd)
}
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(HTMLUtils)
Loading required package: R2HTML
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/HTMLUtils/BasicHTML.Rd_%03d_medium.png", width=480, height=480)
> ### Name: BasicHTML
> ### Title: creates a basic HTML page displaying plots and annota
> ### Aliases: BasicHTML
>
> ### ** Examples
>
>
>
> # if (interactive()){
>
>
> owd=setwd(tempdir())
>
>
> BasicHTML(cmds = list("plot(rnorm(100));","plot(1:10);"),
+
+
+ HTMLobjects = list("Fig1.png", "Fig2.png"),
+
+
+ Captions=c("Gaussian noise","seq 1:10"),
+
+
+ MenuLabels = c("Marvel at the graph below","scatterplots are nice"),
+
+
+ title="Test Page",width=480, height=480, verbose=1, JSCPATH = NULL)
creating graph Fig1.png
creating graph Fig2.png
>
>
>
>
>
> #example with plots and graphfiles having been generated beforehand:
>
>
> # png("Fig1.png");
>
>
> plot(rnorm(100));
>
>
> # dev.off()
>
>
> # png("Fig2.png");
>
>
> plot(1:10);
>
>
> # dev.off();
>
>
>
>
>
> BasicHTML( HTMLobjects = list("Fig1.png", "Fig2.png"),
+
+
+ Captions=c("Gaussian noise","seq 1:10"),
+
+
+ MenuLabels = c("Marvel at the graph below","scatterplots are nice"),
+
+
+ title="Test Page",
+
+
+ width=480, height=480, verbose=1, JSCPATH = NULL);
>
>
>
>
>
> #example with absolute paths for graphfiles :
>
>
> Fig1 <- paste(tempdir(),"/Fig1.png",sep="")
>
>
> # png(Fig1);
>
>
> plot(rnorm(100));
>
>
> # dev.off()
>
>
> Fig2 <- paste(tempdir(),"/Fig2.png",sep="")
>
>
> # png(Fig2);
>
>
> plot(1:10);
>
>
> # dev.off();
>
>
>
>
>
> BasicHTML( HTMLobjects = list(Fig1, Fig2),
+
+
+ Captions=c("Gaussian noise","seq 1:10"),
+
+
+ MenuLabels = c("Marvel at the graph below","scatterplots are nice"), title="Test Page",
+
+
+ width=480, height=480, verbose=1, JSCPATH = NULL);
>
>
> #cleanup:
>
>
> #system(paste("rm ", Fig1));system(paste("rm ", Fig2))
>
>
>
>
>
> #example with sorted table:
>
>
> x <- cbind.data.frame(x1 = round(rnorm(10),3), x2 = round(runif(10),3));
>
>
> attr(x, "HEADER") <- "some random numbers";
>
>
> BasicHTML(HTMLobjects = list("Fig1.png", x, "Fig2.png"),
+
+
+ Captions=c("Gaussian noise","Gaussian and uniform random numbers", "seq 1:10"),
+
+
+ file = paste(Sys.getenv("HOME"), "/public_html/tmp/tmp.html",sep=""),
+
+
+ JSCPATH = "../jsc");
../jsc does not exist. Boldly copying that directory to the base html directory.Error in file(file, ifelse(append, "a", "w")) :
cannot open the connection
Calls: BasicHTML -> MyReportBegin -> cat -> file
In addition: Warning message:
In file(file, ifelse(append, "a", "w")) :
cannot open file '/home/ddbj/public_html/tmp/tmp.html': No such file or directory
Execution halted