if \'div\' is \'TRUE\') is used to accommodate the attributes.',
" hwrite(1:3, k=1:2)",df)
writeExample(df,p,cw,centerExample=FALSE)
## 3.2. text elements
hwrite('3.2. Text element specific arguments',p,heading=2)
df=appendExample('heading',paste('Changes the heading level of the HTML element. Heading styles can be modified in the ',hwrite('current', link='hwriter.css'), ' CSS stylesheet.',sep=''),
"## p=openPage('test.html')
hwrite('Heading 1', p, heading=1)
hwrite('Heading 2', p, heading=2)
hwrite('Heading 3', p, heading=3)
## closePage(p)")
df=appendExample('style\nclass',paste("Uses an CSS style (inline) or a CSS class (defined in the ",hwrite('current', link='hwriter.css')," stylesheet) to render the HTML element.
CSS styles are versatile and allow to change the current typeface, color, margins, font, boldness, italic, padding, alignement... See the
W3C reference or this
wizard to generate new styles.
By default, the style is changed on the fragment of a sentence, using the $
HTML tag. Use the combination with the div argument to change the style of a whole section.",sep=''),
"## p=openPage('test.html', link.css='hwriter.css')\n
hwrite('The fox ', p, style='font-weight: bold')
hwrite('jumps over ', p, style='font-family: monospace;color: #ff2233')
hwrite('the wall.', p, style='text-align: right; font-style: italic')\n
hwrite('hwriter', p, div=TRUE, style='margin:16px; font-size:150%; text-align:right')\n
hwrite('Socrates was a Classical Greek philosopher.', p, class='king', div=TRUE)\n
## closePage(p)",df)
writeExample(df,p,cw)
## 3.3 vector
hwrite('3.3. Vector specific arguments',p,heading=2)
df=appendExample('dim','Sets the dimension of the output HTML table.',
"hwrite(1:6, @test, dim=c(2,3))")
df=appendExample('byrow','Controls if the output HTML table should be filled by rows first. If set to "FALSE", the table is filled by columns first. Default is "FALSE".',
"hwrite(1:6, @test, dim=c(2,3), byrow=TRUE)",df)
df=appendExample('names','Controls if the names of a named vector should be shown. Default is "TRUE".',
"## p=openPage('test.html')
z=c(red=0.5, green=0.6, blue=0.7)
hwrite(z, p, br=TRUE)
hwrite(z, p, names=FALSE)
## closePage(p)",df)
writeExample(df,p,cw)
## 3.4. table
hwrite('3.4. Matrix/table and vector specific arguments',p,heading=2)
df=appendExample('border',"Specifies the table border width. A value of 0 implies that no borders will be drawn. This argument may interfere with the \'border\' CSS style attribute.",
"hwrite(iris[1:4,1:2], @test, border=0)")
df=appendExample('row.names\ncol.names','Specifies if the row (resp. column) names should be displayed.',
"## p=openPage('test.html')\n
hwrite(iris[1:2,1:2], p, br=TRUE, row.names=FALSE)\n
hwrite(iris[1:2,1:2], p, br=TRUE, row.names=FALSE, col.names=FALSE)\n
## closePage(p)",df)
df=appendExample('cellspacing\ncellpadding',"Defines the padding and spacing space in pixels between cells. These arguments may interfere with the \'border\' and \'padding\' CSS style attributes.",
"hwrite(iris[1:2,1:2], @test, center=TRUE, br=TRUE, row.bgcolor='#ffaaaa', cellspacing=10, table.class='raw')
",df)
df=appendExample('width\ncol.width',"Defines global table width and column widths in HTML units (pixels or %).\n'width' specifies the table global width.\n'col.width' contains either a vector of widths (of size equals to the number of columns) which may contain NAs or a named vector of widths which point to some column names.",
"## p=openPage('test.html')\n
hwrite(iris[1:2,1:2], p, br=TRUE, width='150px', row.names=FALSE, col.names=FALSE)\n
hwrite(iris[1:2,1:2], p, br=TRUE, col.width=c(Sepal.Length='150px'))\n
## closePage(p)",df)
df=appendExample('style\nclass\nbgcolor\nlink\n...',"Distributes an attribute on table cells, using R recycling rules.
'style' and 'class' distributes the HTML CSS styling attributes, 'bgcolor' distributes the background color HTML attribute but any valid HTML attribute can be used.
Value of the attribute could be either a character vector or a matrix and may contain NAs to omit cells. Matrices may contain one extra row and/or column to target heading cells.",
"## p=openPage('test.html')\n
hwrite(iris[1:2,1:2], p, br=TRUE, style=matrix(c(NA, 'color:#ff0000', 'color:#0000ff; font-style:italic; text-align:right', NA),nr=2,nc=2))\n
hwrite(iris[1:2,1:2], p, br=TRUE, bgcolor=matrix(c('#aaffaa', NA, '#ffffaa', '#ffffff','#aaaaff', NA),nr=3,nc=2))\n
hwrite(1:4, p, br=TRUE, bgcolor=c('#66ffff', '#99ffee', '#ccffdd', '#ffffcc'), link=1:4)\n
hwrite(array(1:20, dim=c(4,5)), p, br=TRUE, bgcolor=c('#ffffff', '#ffbbaa', '#ff9977', '#ffbbaa', '#ff5500'), link=matrix(1:4, nr=2, nc=2))\n
## closePage(p)",df)
df=appendExample('row.style\ncol.style\nrow.bgcolor\ncol.bgcolor\nrow.link\ncol.link\nrow.*\ncol.*',"Distributes an attribute on table cells, according to row/columns.
The argument may contain a list of vectors of values or a vector of values. Named lists (or vectors) point the corresponding rows/columns, according to their names. Unnamed lists (or vectors) point the rows/columns in the numeric order and NAs can be used to omit rows/columns. If sizes don't match, values are recycled using R rules.",
"## p=openPage('test.html')\n
hwrite(iris[1:2,1:2], p, br=TRUE, row.bgcolor='#ffffaa')\n
hwrite(iris[1:2,1:2], p, br=TRUE, row.style=list('font-weight:bold'), col.style=list(Sepal.Length = 'text-align:left; color:#aa0000'))\n
hwrite(iris[1:3,1:2], p, br=TRUE, col.bgcolor=list(Sepal.Width=c('#66ffff', '#99ffee', '#ccffdd', '#ffffcc')), row.link=list(NA, c('a', 'b'), NA))\n
## closePage(p)",df)
df=appendExample('table.style\ntable.class\ntable.*',"Uses a global table attribute to render the HTML table.
The attribute is added to the main $ tag and should contain a single value. Some uses include setting of the CSS 'border' and 'margin' attributes that cannot be distributed on cells.",
"## p=openPage('test.html')\n
hwrite(iris[1:2,1:2], p, br=TRUE, table.style='font-family: monospace ; border-spacing: 5px; border-collapse: collapse; background-color: white')\n
hwrite(iris[1:2,1:2], p, br=TRUE, table.frame='void')\n
## closePage(p)",df)
writeExample(df,p,cw)
closePage(p)
## open browser
write(paste('Opening a web browser on', filename, '...'),'')
if (interactive()) try(browseURL(paste("file://", filename, sep = "")))
write("OK. A web page showing all the examples should have been opened.",'')
}
hwriter/R/page.R 0000644 0001751 0000144 00000003662 12376052145 013230 0 ustar hornik users ## page related functions
openPage=function(filename, dirname=NULL, title=filename, link.javascript=NULL,
link.css=NULL, css=NULL, head=NULL, charset="utf-8", lang="en",
head.attributes=NULL, body.attributes=NULL) {
if (!is.null(dirname)) {
if (!file.exists(dirname)) dir.create(dirname, recursive=TRUE, showWarnings=FALSE)
filename = file.path(dirname, filename)
}
page = file(filename,'wt')
doctype = '\n'
meta = hmakeTag('meta',NULL,'http-equiv'='Content-Type',content=paste("text/html; charset=", charset, sep=''), newline=FALSE)
if (!is.null(link.javascript)) link.javascript = paste(hmakeTag('script', language='JavaScript', src=link.javascript), collapse='\n')
if (!is.null(link.css)) link.css = paste(hmakeTag('link', rel='stylesheet', type='text/css', href=link.css), collapse='\n')
if (!is.null(css)) css = paste(hmakeTag('style', css), collapse='\n')
head = paste(meta, hmakeTag('title',title), head, link.javascript, link.css, css, sep='\n')
head = do.call(hmakeTag, c(list('head', head, newline=TRUE), head.attributes))
bodyStart = do.call(hmakeTag, c(list('body', NULL), body.attributes))
bodyStart = substr(bodyStart, 1, regexpr('', bodyStart)-1)
hwrite(paste(doctype, "", head, bodyStart, sep=''), page)
page
}
getHwriterVersion=function() {
(sessionInfo()$otherPkgs)[['hwriter']]$Version
}
closePage=function(page, splash=TRUE) {
hwriterlink = hwrite('hwriter', link='http://www.embl.de/~gpau/hwriter/index.html')
if (splash) hwrite(paste('\n
(Page generated on ', date(), ' by ', hwriterlink, ' ', getHwriterVersion(), ')', sep=''), page, br=TRUE)
else hwrite('\n
', page, br=TRUE)
hwrite('', page, br=FALSE)
close(page)
}
hwriter/MD5 0000644 0001751 0000144 00000002302 14224012707 012260 0 ustar hornik users 20dc1f80585a1fb471910ea9916878b7 *CHANGES
d8ce76c44e9d1c2cad2e335049906480 *DESCRIPTION
7b723fe2a1cfd0457d213bff5dfb9ee2 *NAMESPACE
512b7926dbec0e46f82202d2c21407df *R/example.R
2c50a111830850d99f808d540e51dd2b *R/hwriter.R
50f1a547e6099eba1456a6871b40cafe *R/page.R
3f14c04b3d1b66d785219ac0f224f479 *R/table.R
8112c0ff3312637dbdc1a46f72452087 *TODO
c6e14eb80fddcd55a36ae5a606b01335 *build/vignette.rds
8fc0302ea00305bfb331e20312f94758 *inst/doc/hwriter.R
dd5aefebaa44ad59ca80da496a71886f *inst/doc/hwriter.Rnw
bcfe799a4a88932ec17acb5b82b88b8e *inst/doc/hwriter.pdf
a5bd1a6bd2445616817da1beef6cc06e *inst/images/hwriter.css
5ae0289b1f93ed9f135851cb93d66fde *inst/images/iris1.jpg
a20525b70f7238568257e03399fbe77d *inst/images/iris2.jpg
f8702b42db632716d9dcce5314d0e7ff *inst/images/iris3.jpg
31d68e85d2d872e8eeb6f071d84abf9d *inst/images/motif.png
3d195a1fdbe2c368a8ea0eed8862446e *inst/scripts/build.sh
b1be682a81f0212896eb59ffd56048aa *man/hmakeTag.Rd
0e3437193e043fa7424c7a7085ac537b *man/hwrite.Rd
2db9472c0e65d9c0b95405ed1925296c *man/hwriteImage.Rd
9494fe35e5be12a31a43fd18303c556e *man/hwriter-package.Rd
07bb9bd51103bf3eeec939c226e412be *man/openPage.Rd
dd5aefebaa44ad59ca80da496a71886f *vignettes/hwriter.Rnw
hwriter/inst/ 0000755 0001751 0000144 00000000000 11473677035 012746 5 ustar hornik users hwriter/inst/doc/ 0000755 0001751 0000144 00000000000 12376054107 013503 5 ustar hornik users hwriter/inst/doc/hwriter.R 0000644 0001751 0000144 00000000340 14224007240 015275 0 ustar hornik users ### R code from vignette source 'hwriter.Rnw'
###################################################
### code chunk number 1: example
###################################################
library('hwriter')
example('hwriter')
hwriter/inst/doc/hwriter.Rnw 0000644 0001751 0000144 00000003414 11473525402 015657 0 ustar hornik users % \VignetteIndexEntry{Description of the package hwriter}
% \VignetteKeywords{HTML, hwriter}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{hyperref}
\clearpage
\parindent 0in % Left justify
\newcommand{\Rpackage}[1]{\textsf{#1}}
\newcommand{\Rfunction}[1]{\textit{#1}}
\newcommand{\Robject}[1]{\texttt{#1}}
\newcommand{\Rclass}[1]{{\textit{#1}}}
\newcommand{\Rmethod}[1]{{\textit{#1}}}
\newcommand{\Rfunarg}[1]{{\textit{#1}}}
\SweaveOpts{eps=FALSE}
\title{The hwriter package}
\author{Gregoire Pau}
\begin{document}
\maketitle
\section{Description}
The package \Rpackage{hwriter} is an easy-to-use package able to format and output R (from the R-project) objects in HTML format.
It supports advanced formatting, tables, CSS styling, images and provides a convenient mapping between R tables and HTML tables.
The project page is \url{http://www.ebi.ac.uk/~gpau/hwriter}.
The package provides the following functions (but most of the job is carried out by \Rfunction{hwrite}):
\begin{itemize}
\item \Rfunction{hwrite} outputs an R object in HTML format.
\item \Rfunction{hwriteImage} writes an image.
\item \Rfunction{openPage, closePage} handles HTML page/document creation.
\item \Rfunction{hmakeTag} is a low-level HTML tag formatting function.
\end{itemize}
All the functions are documented in the manual pages. Please check them for reference.
\section{Example}
It is not easy to render what an HTML writing package could do in a PDF document. The following example produces a local web page
named \Rfunction{example-hwriter.html} which contains many documented examples, all with R sources and resulting HTML outputs.
%
<>=
library('hwriter')
example('hwriter')
@
%
\end{document}
hwriter/inst/doc/hwriter.pdf 0000644 0001751 0000144 00000061222 14224007240 015653 0 ustar hornik users %PDF-1.5
%
1 0 obj
<< /Type /ObjStm /Length 1998 /Filter /FlateDecode /N 30 /First 221 >>
stream
xYYs6~[Tyt2/Ŏ8ݤ䁑`L$9}o.xd$ ,#8.QD8h"9'Q'.\8%r8&@rA-`:~a${D*30|0Lr}XPjLaI>Ҵ KO8LB+~zбɂyD
wlF&]M
'@Ȳe/a$1AiWض`y\_WL%~sܚdfKIbayjy!v7I<_\2NtZL_4r
ZxeD! yu.rQgH(N(3tʼD; $ ,:1iNf9Ǹb668ЛsXyʀQ}QmI>- ^]}NMU V*o jvJr7) Jx\%Gustx
BVМ&1}6W{0أ3gvfj 5Vr|=d<Cg,тa4pazFh˶8(s`
EK
~18EȮ<}CF|lyv
R,jә07&\,1hi/-
Kү&4VI_a`۰9.nY>Hm:x0m_W ghz4[)g߈X XlH){;eźZm-se boK{B:"\+GUGblԲ5x[ Q6HXFI]~\ 5Wg[bRXFY.Wu$ =tDzEN"`tb-zodi" }i#ZbszJU.&knN6Iܰ+P
vimMd+x6~si~
T
XO+-sn1{CW*\[iu";Iג~Q.者өc3l#LR0m9(r(jj' M=#مd4<ɦޔ3AS Hº 6A|
Ї͵(TGc"wWs
kɰmP#Lv{1|мLVֶkRֿhn[w=Cik#=a}'J&
ncp(o!w%Hgax2I=mc_WżF~d3|7ׁ҅}mO54 {r#p?k]]oߎpF!pI̖?h;,j3xg{e5"l$d@N
DlTg(d姊 9png^k$+*<@$uׄE+¢`^7o")T\?BiWKl>gt
RT?=C|J^r_ގs qOȦ䧑=I@;vE|a
ph{>n週wr:s`C[`}*;@i_uƎxtE>Mmȶ6:y6 n./ VnLui+Qs[g4r)Oy˃^"R
endstream
endobj
32 0 obj
<< /Subtype /XML /Type /Metadata /Length 1387 >>
stream
GPL Ghostscript 9.55.0
2022-04-08T12:29:52+02:00
2022-04-08T12:29:52+02:00
LaTeX with hyperref
endstream
endobj
33 0 obj
<< /Filter /FlateDecode /Length 2809 >>
stream
xZKs
Wq6;RJ"IkIҒ.9g@ 3KVJ
n_W+wgju}뙦UnٳWQ}Ư2_lj{wS]ީnSeknJo",kbaS2u8cw>gmwo@⠝b:Mؽe.o^ȚSw79(Yi[lCXm]z[=mƔ4Ƞ]`Kdd 0
sc|o`Kd