Package 'HTMLUtils'

Title: Facilitates Automated HTML Report Creation
Description: Facilitates automated HTML report creation, in particular framed HTML pages and dynamically sortable tables.
Authors: "Markus Loecher, Berlin School of Economics and Law (BSEL)" <[email protected]>
Maintainer: "Markus Loecher, Berlin School of Economics and Law (BSEL)" <[email protected]>
License: GPL
Version: 0.1.9
Built: 2024-12-21 06:27:15 UTC
Source: CRAN

Help Index


Facilitates Automated HTML Report Creation

Description

Facilitates automated HTML report creation, in particular

framed HTML pages and dynamically sortable tables.

Details

Package: HTMLUtils
Type: Package
Title: Facilitates Automated HTML Report Creation
Version: 0.1.7
Date: 2015-01-17
Depends: R2HTML
Suggests:
Author: "Markus Loecher, Berlin School of Economics and Law (BSEL)" <[email protected]>
Maintainer: "Markus Loecher, Berlin School of Economics and Law (BSEL)" <[email protected]>
License: GPL
LazyLoad: yes
Packaged: 2012-05-17 21:56:35 UTC; mloecher
Repository: CRAN
Date/Publication: 2012-05-18 05:59:13

Author(s)

"Markus Loecher, Berlin School of Economics and Law (BSEL)" <[email protected]>


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.

Usage

BasicHTML(cmds = NULL, HTMLobjects, Captions, MenuLabels, Comments = NULL,

    file = "tmp.html", title = "", width = 480, height = 480,

    FRAMES = FALSE, JSCPATH = "jsc", LaunchPage = FALSE, APPEND = FALSE,

    href = NULL, verbose = 0)

Arguments

cmds

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)" <[email protected]>

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)

}

creates a framed HTML page displaying plots and annotations

Description

Creates a framed 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.

The user has a great deal of flexibility in choosing appropriate directory structures.

Usage

FramedHTML(cmds = NULL, basepath = c("./", paste(Sys.getenv("HOME"),

    "/public_html/", sep = ""))[1], path = "tmp", Graphpath = "Figures/",

    DiagnosticsPath = "Diagnostics", file = "tmp", HTMLobjects,

    Captions, MenuLabels1, MenuLabels2, href = NULL, Comments = NULL,

    title = "", width = 480, height = 480, FRAMES = FALSE, JSCPATH = "jsc",

    REFRESH = "", img.logo.path = paste(Sys.getenv("HOME"), "/public_html/",

        sep = ""), img.logo = NULL, img.href = "http://www.sensenetworks.com",

    APPEND = FALSE, verbose = 1)

Arguments

cmds

list of commands that generates the plots. If missing, the graphfiles are assumed to exist already.

basepath

base path of ‘⁠public_html⁠’ directory

path

subdirectory of basepath; will be created if non existing

Graphpath

subdirectory of ‘⁠basepath/path/⁠’ containing the graphfiles; will be created if non existing

DiagnosticsPath

subdirectory of ‘⁠basepath/path/⁠’ containing the graphfiles; will be created if non existing

file

file name of main page; '.html' extension will be added. The '_main' and '_menu' pages use this base as well.

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

MenuLabels1

vector of labels for the menu navigation page. It helps to keep these succinct and short !.

MenuLabels2

vector of labels for the main page; these go on top of the individual graphs, so they are complementary to the captions.

href

links to other HTML pages

Comments

Text/comments to be written between the graphs

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.

REFRESH

Meta refresh is a method of instructing a web browser to automatically refresh the current web page after a given time interval

img.logo.path

path to search for the logo pic in the frame

filename of logo to display

img.href

link of logo to point to.

APPEND

append to existing HTML page ?

verbose

level of verbosity

Value

no return values

Note

There is not much eror checking. In particular, the lengths of the argumentscmds, graphfiles, Captions, MenuLabels1, MenuLabels2 need to be all the same !

Author(s)

"Markus Loecher, Berlin School of Economics and Law (BSEL)" <[email protected]>

See Also

BasicHTML

Examples

if (interactive()){

  #example with plots and graphfiles being generated on the fly:

  owd=setwd(tempdir())

  system("mkdir Figures")



FramedHTML(cmds = list("plot(rnorm(100));","plot(1:10);"),

           HTMLobjects =list("Fig1.png", "Fig2.png"),

           Captions=c("Gaussian noise","seq 1:10"),

           MenuLabels1 = c("Label1","Label2"),

           MenuLabels2 = c("Marvel at the graph below","scatterplots are nice"),

           Comments  = c("100 random numbers","Simple plot"), title="Test Page",

           width=480, height=480, verbose=1)





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



FramedHTML( HTMLobjects = list("Fig1.png", "Fig2.png"),

   Captions=c("Gaussian noise","seq 1:10"),

  MenuLabels1 = c("Label1","Label2"),

   MenuLabels2 = c("Marvel at the graph below","scatterplots are nice"),

   Comments  = c("100 random numbers","Simple plot"), title="Test Page",

  width=480, height=480, verbose=1);



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



 FramedHTML( HTMLobjects = list(Fig1, Fig2), Captions=c("Gaussian noise","seq 1:10"),

    MenuLabels1 = c("Label1","Label2"),

    MenuLabels2 = c("Marvel at the graph below","scatterplots are nice"),

    Comments  = c("100 random numbers","Simple plot"),

    title="Test Page",width=480, height=480, verbose=1);

    #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";

  FramedHTML(HTMLobjects = list("Fig1.png", x, "Fig2.png"),

    MenuLabels1 = c("Label1","Label2","Label3"),

    MenuLabels2 = c("Marvel at the graph below","JavaScript rocks","scatterplots are nice"),

    Captions=c("Gaussian noise","Gaussian and uniform random numbers", "seq 1:10"),Comments = NULL,

    path = "tmp", file = "index");



  #example with sorted tables only, no figures:

  x <- cbind.data.frame(x1 = round(rnorm(10),3), x2 = round(runif(10),3));

  attr(x, "HEADER") <- "some random numbers";

  y <- cbind.data.frame(y1 = rbinom(10,50,0.3), y2 = rbinom(10,100,0.15));

  attr(y, "HEADER") <- "rbinom";

  FramedHTML(HTMLobjects = list( x, y),

           MenuLabels1 = c("x","y"),

           MenuLabels2 = c("JavaScript rocks","Secret numbers"),

           Captions=c("Gaussian and uniform random numbers", "Binomial draws"),Comments = NULL,

           path = "tmp", file = "index");



  setwd(owd)

}

adds an href item to the current HTML page

Description

adds an href item to the current HTML page

Usage

HTMLhref(href, txt, file = get(".HTML.file"), append = TRUE)

Arguments

href

HTML reference/URL

txt

text to display

file

file to write to

append

append to file (default TRUE)

Author(s)

"Markus Loecher, Berlin School of Economics and Law (BSEL)" <[email protected]>


create sortable table

Description

create sortable table using JavaScript components in JSCPATH directory

Usage

HTMLsortedTable(x, TITLE = "", HEADER = "", file = "tmp.html",

    JSCPATH = "jsc", path = paste(Sys.getenv("HOME"), "/public_html/",

        sep = ""), debug = 0)

Arguments

x

data frame or matrix with column names

TITLE

title for the HTML page

HEADER

header to display for the sorted table

file

file name of main page; '.html' extension will be added. The '_main' and '_menu' pages use this base as well.

JSCPATH

path that should contain the jsc components. If non existing, user will be prompted for installation.

path

directory to create the file in

debug

level of verbosity

Author(s)

"Markus Loecher, Berlin School of Economics and Law (BSEL)" <[email protected]>


installs the JS components

Description

prompts the user to install the JS components to the relevant directory, which enables dynamically sortable tables.

Usage

InstallJSC(JSCPATH)

Arguments

JSCPATH

path to install the jsc directory to. Recommended is the base public html directory.

Author(s)

"Markus Loecher, Berlin School of Economics and Law (BSEL)" <[email protected]>


create appropriate directory structure if needed

Description

create appropriate directory structure if needed

Usage

makePathName(path, MakePath = TRUE, verbose = 0)

Arguments

path

path to create

MakePath

if yes, create directory if not exists

verbose

level of verbosity

Value

returns absolute path

Author(s)

"Markus Loecher, Berlin School of Economics and Law (BSEL)" <[email protected]>


Begins / Ends a new HTML report output

Description

Those two functions handle the beginning and the ending of a HTML report, by writing the

HTML <body><head><title></title></head>...</body> tags and their options. When working manually, the user may need to use it's own functions or to explicitly write to a file using cat("", file=).

Usage

myHTMLInitFile(outdir = tempdir(), filename = "index", extension = "html", 


    HTMLframe = TRUE, BackGroundColor = "FFFFFF", BackGroundImg = "", 


    Title = "R output", NavTitle = "", CSSFile = "R2HTML.css", 


    useLaTeX = TRUE, useGrid = TRUE, img.logo.path = paste(Sys.getenv("HOME"), 


        "/public_html/", sep = ""), img.logo = "logo-SenseNetworks.png", 


    img.href = "http://www.sensenetworks.com", JSCPATH = NULL, 


    APPEND = FALSE, REFRESH = "")

Arguments

outdir

directory to store the output

filename

target HTML report filename

extension

target HTML report extension (htm, html,...)

HTMLframe

should the output be handled by frames [boolean]

BackGroundColor

option bgcolor for HTML tag <body>

BackGroundImg

option background for HTML tag <body>

Title

string to pass to HTML <title> tag

NavTitle

title of navigation page

CSSFile

path and name of a CSS file to use

useLaTeX

boolean - add required references to javascript AsciiMathML in order to use as.latex

useGrid

boolean - add required references to javascript grid in order to use R2HTML grid functions

img.logo.path

path to search for the logo pic in the frame

filename of logo to display, if NULL no logo to display!

img.href

link of logo to point to.

JSCPATH

directory that contains the javascript code

APPEND

append to existing HTML page ?

REFRESH

Meta refresh is a method of instructing a web browser to automatically refresh the current web page after a given time interval.

Author(s)

"Markus Loecher, Berlin School of Economics and Law (BSEL)" <[email protected]>


gracefully initializes the HTML page

Description

gracefully initializes the HTML page

Usage

MyReportBegin(file = "report.html", title = "My Report Title", 


    header = NULL)

Arguments

file

filename

title

title for HTML page

header

header yes/no

Author(s)

"Markus Loecher, Berlin School of Economics and Law (BSEL)" <[email protected]>


gracefully finalizes the HTML page

Description

gracefully finalizes the HTML page

Usage

MyReportEnd(file = "report.html")

Arguments

file

file to append to

Author(s)

"Markus Loecher, Berlin School of Economics and Law (BSEL)" <[email protected]>