[med-svn] [r-cran-hwriter] 04/06: New upstream version 1.3.2
Andreas Tille
tille at debian.org
Fri Oct 20 05:23:05 UTC 2017
This is an automated email from the git hooks/post-receive script.
tille pushed a commit to branch master
in repository r-cran-hwriter.
commit 50041d55855ae211603d426882e2a813603a2431
Author: Andreas Tille <tille at debian.org>
Date: Fri Oct 20 07:20:15 2017 +0200
New upstream version 1.3.2
---
CHANGES | 45 +++++++
DESCRIPTION | 13 ++
MD5 | 24 ++++
NAMESPACE | 8 ++
R/example.R | 317 +++++++++++++++++++++++++++++++++++++++++++++
R/hwriter.R | 152 ++++++++++++++++++++++
R/page.R | 36 +++++
R/table.R | 269 ++++++++++++++++++++++++++++++++++++++
TODO | 7 +
build/vignette.rds | Bin 0 -> 229 bytes
debian/README.test | 8 --
debian/changelog | 13 --
debian/compat | 1 -
debian/control | 28 ----
debian/copyright | 31 -----
debian/docs | 2 -
debian/examples | 1 -
debian/lintian-overrides | 2 -
debian/rules | 3 -
debian/source/format | 1 -
debian/tests/control | 3 -
debian/tests/run-unit-test | 18 ---
debian/watch | 2 -
inst/doc/hwriter.R | 9 ++
inst/doc/hwriter.Rnw | 56 ++++++++
inst/doc/hwriter.pdf | Bin 0 -> 83033 bytes
inst/images/hwriter.css | 49 +++++++
inst/images/iris1.jpg | Bin 0 -> 5486 bytes
inst/images/iris2.jpg | Bin 0 -> 3388 bytes
inst/images/iris3.jpg | Bin 0 -> 4135 bytes
inst/images/motif.png | Bin 0 -> 3594 bytes
inst/scripts/build.sh | 15 +++
man/hmakeTag.Rd | 55 ++++++++
man/hwrite.Rd | 132 +++++++++++++++++++
man/hwriteImage.Rd | 82 ++++++++++++
man/hwriter-package.Rd | 44 +++++++
man/openPage.Rd | 102 +++++++++++++++
vignettes/hwriter.Rnw | 56 ++++++++
38 files changed, 1471 insertions(+), 113 deletions(-)
diff --git a/CHANGES b/CHANGES
new file mode 100644
index 0000000..6ec9e7b
--- /dev/null
+++ b/CHANGES
@@ -0,0 +1,45 @@
+version 1.3:
+- links containing NA values are not translated to empty <a> tags anymore
+- added head.attributes and body.attributes in openPage()
+- example(hwriter) now uses file:// when calling browseURL to prevent page opening problems
+- hmakeTags now handles NA tags correctly (no tags)
+
+version 1.1:
+- example-hwriter.html contains now valid XHTML 1.0 code
+
+version 1.0: (CRAN)
+- major release
+- before: automatic 'style', now: 'table.style' and 'style'
+- no NA anymore in default arguments
+- extra attributes *, row.*, col.*, table.* are now consumed
+- div sections
+- nice example with CSS stylesheet
+- wiki attribute removed
+- name anchor
+
+version 0.95:
+- fixed bug on rowcol naming
+- fixed bug on class, id and onClick support
+
+version 0.94:
+- hwrite uses table.style instead of style for <table> styling
+- new logic for rowcol processing
+- hwrite supports table.class, table.id and table.onClick
+- hmakeTag supports matrices
+- hwrite supports class, id and onClick arguments
+- openPage supports CSS and Javascript
+- hwrite supports the 'table' argument for single element vectors
+
+version 0.93: (CRAN)
+- remove splash
+- writeCells removed
+- simpler doc
+
+version 0.92:
+- pstrick removed from Rnw
+- fixed width table
+- openPage head
+- inst/images + system.file to load images
+- hwriteImage with vector url.image
+
+
diff --git a/DESCRIPTION b/DESCRIPTION
new file mode 100755
index 0000000..4b75bca
--- /dev/null
+++ b/DESCRIPTION
@@ -0,0 +1,13 @@
+Package: hwriter
+Title: HTML Writer - Outputs R objects in HTML format
+Version: 1.3.2
+Author: Gregoire Pau <gregoire.pau at gmail.com>
+Depends: R (>= 2.6.0)
+Description: Easy-to-use and versatile functions to output R objects in
+ HTML format
+Maintainer: Gregoire Pau <gregoire.pau at gmail.com>
+License: LGPL-2.1
+Packaged: 2014-09-08 20:22:43 UTC; paug
+Repository: CRAN
+Date/Publication: 2014-09-10 09:07:38
+NeedsCompilation: no
diff --git a/MD5 b/MD5
new file mode 100644
index 0000000..418b5b0
--- /dev/null
+++ b/MD5
@@ -0,0 +1,24 @@
+20dc1f80585a1fb471910ea9916878b7 *CHANGES
+8f033bdceec8600d3334ee3cdf24de2e *DESCRIPTION
+6f6dfbf449b36e7a2e7b429e6266d0df *NAMESPACE
+512b7926dbec0e46f82202d2c21407df *R/example.R
+2c50a111830850d99f808d540e51dd2b *R/hwriter.R
+50f1a547e6099eba1456a6871b40cafe *R/page.R
+3f14c04b3d1b66d785219ac0f224f479 *R/table.R
+8112c0ff3312637dbdc1a46f72452087 *TODO
+61c5b1f3ed6230d8c569dc4e69fb7065 *build/vignette.rds
+8fc0302ea00305bfb331e20312f94758 *inst/doc/hwriter.R
+dd5aefebaa44ad59ca80da496a71886f *inst/doc/hwriter.Rnw
+eca37937e4f2b64b40cdf31185c3bdeb *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
+93fb3a4cb568f0b4716e0b84f0e46391 *man/hwriter-package.Rd
+07bb9bd51103bf3eeec939c226e412be *man/openPage.Rd
+dd5aefebaa44ad59ca80da496a71886f *vignettes/hwriter.Rnw
diff --git a/NAMESPACE b/NAMESPACE
new file mode 100644
index 0000000..c117945
--- /dev/null
+++ b/NAMESPACE
@@ -0,0 +1,8 @@
+export('hwrite', 'openPage', 'closePage', 'hwriteImage',
+ 'hmakeTag')
+
+S3method(hwrite, character)
+S3method(hwrite, numeric)
+S3method(hwrite, matrix)
+S3method(hwrite, array)
+S3method(hwrite, data.frame)
diff --git a/R/example.R b/R/example.R
new file mode 100644
index 0000000..b6607a5
--- /dev/null
+++ b/R/example.R
@@ -0,0 +1,317 @@
+appendExample=function(argument,description,example,df=NULL) {
+ p=file()
+
+ ## replaces @test by p
+ exampleval=gsub('@test','p',example)
+
+ z=eval(parse(text=exampleval))
+ if (!is.null(z)) {
+ z=gsub('<','<',z)
+ z=gsub('>','>',z)
+ write(z,p)
+ }
+ write('\n',p)
+ result=paste(readLines(p),collapse='')
+ close(p)
+
+ ## replaces @test by test.html
+ example=gsub('@test','\'test.html\'',example)
+
+ ## escapes linebreaks in HTML
+ description=gsub('\n','<br/>',description)
+ example=gsub('\n','<br/>',example)
+
+ ## preserves HTML entities
+ example=gsub('&','&',example)
+ description=gsub('\\$<','<',description)
+ description=gsub('\\$>','>',description)
+
+ ## removes comments
+ example=gsub('## ','',example)
+
+ if (!is.null(argument)) {
+ argument=gsub('\n','<br/>',argument)
+ z=data.frame(Argument=argument,Description=description,Example=example,Result=result)
+ } else z=data.frame(Description=description,Example=example,Result=result)
+
+ if (is.null(df)) df=z
+ else df=rbind(df,z)
+ df
+}
+
+writeExample=function(df,p,cw,centerExample=TRUE) {
+ if (centerExample) hwrite(df,p,row.bgcolor='#ffffaa',row.names=FALSE, col.width=cw,class='tab',col.style=c(Example='font-family:monospace',Result='text-align:center'),row.style='text-align:center')
+ else hwrite(df,p,row.bgcolor='#ffffaa',row.names=FALSE, col.width=cw,class='tab',col.style=c(Example='font-family:monospace'),row.style='text-align:center')
+ }
+
+showExample=function() {
+ tmpdir = tempdir()
+ filename = file.path(tmpdir,'example-hwriter.html')
+
+ ## copying data files
+ imgdir=file.path(system.file(package='hwriter'),'images')
+ images=file.path(imgdir,dir(imgdir))
+ file.copy(images,tmpdir)
+
+ ## opens webpage
+ write(paste('Building the example webpage',filename,'...'),'')
+ p=openPage(filename,link.css='hwriter.css')
+ cw=c(Argument='100px',Description='400px',Example='350px',Result='300px')
+ hwname=paste('hwriter_',getHwriterVersion(),'.tar.gz',sep='')
+ hwriter=hwrite('hwriter',style='font-family:monospace')
+
+ ## introduction
+ text=hwrite('The hwriter package',heading=1,center=TRUE)
+ text=c(text,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, Javascript and provides a convenient mapping between R tables and HTML tables.<br/>')
+ text=c(text,'This is ',hwriter,' version ',getHwriterVersion(),', written by Gregoire Pau. Download ',hwrite(hwname,style='font-family:monospace'),' ',hwrite('here',link=paste('http://www.embl.de/~gpau/hwriter/',hwname,sep='')),' or on ',hwrite('CRAN', link='http://cran.r-project.org/'),'.<br/><br/>')
+ text=c(text,'This page (generated by ',hwriter,') shows examples of the package abilities and illustrates in detail the behavior of the optional arguments used by the function ',hwrite('hwrite()',style='font-family:monospace'),'. All the examples on this page are using the ',hwrite('current',link='hwriter.css'),' CSS stylesheet.')
+ hwrite(paste(text,collapse=''),p,class='intro',div=TRUE)
+
+ ## 1. Simple examples
+ cw=c(Argument='100px',Description='300px',Example='350px',Result='300px')
+ hwrite(hwrite('1. Simple examples',name='se'),p,heading=1)
+ df=appendExample(NULL,'Writes a string.',"hwrite('Hello world !', @test)")
+ df=appendExample(NULL,'Appends HTML elements in a page.\nWrites a string with an hyperlink.',
+ "## p=openPage('test.html')
+ hwrite('Hello', p, link='http://hello.com')
+ hwrite(' world !', p)
+ ## closePage(p)",df)
+ df=appendExample(NULL,'Writes a vector.',"hwrite(1:5, @test)",df)
+ df=appendExample(NULL,'Writes a matrix.',
+ "hwrite(iris[1:2,1:2], @test, row.bgcolor='#ffdc98')",df)
+ df=appendExample(NULL,'Appends HTML elements in a page. Inserts an image.',
+ "## p=openPage('test.html')
+ hwrite('This is an iris flower:', p, br=TRUE)
+ hwriteImage('iris1.jpg', p, br=TRUE)
+ hwrite('',p, br=TRUE)
+ hwrite(c('Plantae','Monocots','Iris'), p)
+ ## closePage(p)",df)
+ df=appendExample(NULL,'Outputs HTML code part.', "hwrite('Monocots', link='http://mc.org')",df)
+ df=appendExample(NULL,'Combines HTML code parts.', "hwrite(c('Plantae', hwrite('Monocots', link='http://mc.org'), 'Iris'), @test)",df)
+ df=appendExample(NULL,'Combines HTML code parts using nested calls.',
+ "img=hwriteImage('iris3.jpg', center=TRUE)
+ cap=hwrite(c('Plantae', hwrite('Monocots', link='http://mc.org'), 'Iris'))
+ hwrite(c(img, cap), @test, dim=c(2,1), center=TRUE)",df)
+ writeExample(df,p,cw)
+
+ ## 2. advanced examples
+ hwrite(hwrite('2. Advanced examples',name='ae'),p,heading=1)
+ cw=c(Argument='100px',Description='400px',Example='200px',Result='300px')
+ df=appendExample(NULL,"CSS styling.",
+ "## p=openPage('test.html')
+ hwrite(paste('The fox jumps ',hwrite('over', link='http://over.com'), ' the ', hwrite('red', style='color:#cc3355'), ' wall.', collapse=''), p, br=TRUE)
+ hwrite(paste('The function', hwrite( 'hwrite()', style='font-family:monospace'), 'is cool !'), p)
+ ## closePage(p)")
+
+ df=appendExample(NULL,"Banner of multisized images, with CSS tiled background and hyperlink.","
+ hwriteImage('iris1.jpg', @test, width=c(50,75,100,125), link=c('http://www.ab1.com', 'http://www.ab2.com', 'http://www.ab3.com', 'http://www.ab4.com'), table.style=' background-image: url(motif.png);background-repeat: repeat')", df)
+
+ df=appendExample(NULL,paste('Named anchors and customized CSS hyperlinks using classes in the ',hwrite('current',link="hwriter.css"),' CSS stylesheet and margins.',sep=''),"
+ ## p=openPage('test.html', link.css='hwriter.css')
+ hwrite('Please select an item:', p, br=TRUE)
+ items=c('Gene', 'mRNA', 'Polypeptide', 'Protein')
+ links=paste('http://en.wikipedia.org/wiki/', items, sep='')
+ hwrite(hwrite(items, class='example', link=links, table=FALSE), p, border=0)
+ sections=c('Simple examples', 'Advanced examples', 'Details')
+ nanchors=c('#se', '#ae', '#de')
+ hwrite(hwrite(sections, class='example2', link=nanchors, table=FALSE), p, dim=c(3,1), style='margin:0px ; padding:8px', table.style='margin-top:20px', border=0)
+ ## closePage(p)",df)
+
+ df=appendExample(NULL,'Pointing columns and rows. Changing background color, alignments, hyperlinks and CSS style.',"
+ colors=c('#ffaaff','#ddaaff','#bbaaff','#99aaff','#55aaff')
+ hwrite(iris[1:7,1:4], @test, center=TRUE, row.bgcolor=list('#aaffaa', '3'='#ffffaa', '5'=colors), col.style=list(Sepal.Length='font-style:italic',Petal.Length='text-align:center'), row.style=list('font-weight:bold'), col.link=list(Sepal.Width=iris$Sepal.Width[1:7]))",df)
+
+ df=appendExample(NULL,'Color scale bar.',"
+ scale=round(seq(0, 1, len=8), 2)
+ colors=rgb(colorRamp(c('#ff0000', '#ffff00', '#ffffff'))(scale), max=255)
+ band=hwrite(scale, @test, bgcolor=colors, style='color: black', col.width=rep(20, 8))
+ ",df)
+
+ df=appendExample(NULL,"Complex layout using borderless tables.",
+ "img=hwriteImage('iris1.jpg', center=TRUE)
+ cap=hwrite(c('Plantae', hwrite('Monocots', link='http://mc.org'), 'Iris'))
+ iris=hwrite(c(img, cap), dim=c(2,1), center=TRUE, border=0)
+ colors=rgb(colorRamp(c('#7f007f', '#aaaaaa'))(seq(0, 1, len=5)), max=255)
+ band=hwrite(c('+', rep(' ',3), '0'), bgcolor=colors, dim=c(5,1), border=0, style='color: white')
+ hwrite(c(iris,band), @test, border=0)",df)
+
+ df=appendExample(NULL,"Combining matrix of images and hyperlinking.","
+ himg=hwriteImage(c('iris1.jpg','iris2.jpg','iris3.jpg'), link=c('http://en.wikipedia.org/wiki/Iris_virginica', 'http://en.wikipedia.org/wiki/Iris_versicolor', 'http://en.wikipedia.org/wiki/Iris_virginica'), table=FALSE)
+ mat=rbind(himg, c('Setosa','Versicolor','Virginica'))
+ rownames(mat)=c('Image', 'Species')
+ hwrite(mat, @test, br=TRUE, center=TRUE, row.bgcolor=list(Species=c('#ffaacc', '#ff88aa', '#ff6688')), col.bgcolor='#ffffaa', row.style=list(Species='text-align:center'))
+ ",df)
+
+ df=appendExample(NULL,'Fancy patchwork. Advanced text formatting.',"
+ cells=matrix('', nr=6, nc=5)
+ hotcolors=rgb(colorRamp(c('#ff0000', '#ffff00', '#ffffff'))(runif(length(cells))), max=255)
+ bgcolor=array(hotcolors, dim=dim(cells))
+ rownames(cells)=1:nrow(cells)
+ patchwork=hwrite(cells, bgcolor=bgcolor, col.width=rep('16px', nrow(cells)))
+ text='La volupté de la chair est une chose de la vie des sens au meme titre que le regard pur, que la pure saveur d\\'un beau fruit sur notre langue...'
+ text=paste(hwrite(text, br=TRUE), hwrite('Rainer Maria Rilke', style='font-style:italic'))
+ hwrite(c(patchwork,text), @test, br=TRUE, center=TRUE, col.width=c(NA,'200px'), style='text-align:justify', border=0, cellspacing=10)
+ ",df)
+
+ df=appendExample(NULL,"Sections (divisions) and CSS styling.","
+ ## p=openPage('test.html')
+ codestyle='margin: 10px; padding: 10px; background-color: #aaffaa; border: solid 1px black; font-family: monospace ; text-align: left'
+ hwrite('Please type the following commands:', p)
+ hwrite(paste(hwrite(c('> library(rgl)', '> example(rgl)'), br=TRUE, table=FALSE), collapse=''), p, style=codestyle, div=TRUE)
+ hwrite('to see nice examples of the package rgl.', p)
+ ## closePage(p)",df)
+
+ df=appendExample(NULL,paste('Styling sections using CSS classes defined in the ',hwrite('current',link="hwriter.css"),' CSS stylesheet.',sep=''),"
+ ## p=openPage('test.html', link.css='hwriter.css')
+ text=paste(hwrite('And the king said to her:', class='narrator'), hwrite('What is the matter with you ?', class='king', div=TRUE), hwrite('And she answered:', class='narrator'), hwrite('Give me your son that we may eat...', class='king', div=TRUE), sep='')
+ hwrite(text, p, div=TRUE, class='textbox')
+ ## closePage(p)",df)
+
+ df=appendExample(NULL,"Use of Javascript through \'onmouseover\' and \'onmouseout\' attributes.","
+ ## p=openPage('test.html')
+ hwrite('Pass the mouse over:', p)
+ hwrite(array(' ',dim=c(6,6)), p, onmouseover=\"this.bgColor='#ffaaaa'\", onmouseout=\"this.bgColor='white'\", bgcolor='white', col.width=rep(18,6), style='padding:0px; margin:0px')
+ ## closePage(p)",df)
+
+ df=appendExample(NULL,'Build HTML tags using \'hmakeTag\' to render additonal HTML objects.',"
+ ## p=openPage('test.html')
+ hwrite('This is an itemized bullet list:', p)
+ li=paste(hmakeTag('li', c('Abstract', 'Methods', 'Results')), collapse='')
+ hwrite(hmakeTag('ul', li, style='font-weight:bold; text-align:left'), p)
+ ## closePage(p)",df)
+
+ writeExample(df,p,cw)
+
+ ## 3. hwrite arguments
+ cw=c(Argument='100px',Description='400px',Example='350px',Result='300px')
+ hwrite(hwrite(paste('3. Detailed description of ',hwrite('hwrite()',style='font-family:monospace'),'arguments'),name='de'),p,heading=1)
+
+ ## 3.1. general arguments
+ hwrite('3.1. General arguments',p,heading=2)
+ df=appendExample('br','Inserts a carriage return (line break, newline) at the end of the HTML element.',
+ "## p=openPage('test.html')
+ hwrite('The fox ', p)
+ hwrite('jumps', p, br=TRUE)
+ hwrite('over the...', p, br=TRUE)
+ ## closePage(p)")
+ df=appendExample('table','Controls if the object should be written as an HTML table. Default is "TRUE" for vectors and matrices, and "FALSE" otherwise. If set to "FALSE", the object is written as a vector (or a matrix) of HTML elements.',
+ "## p=openPage('test.html')
+ hwrite(1:6, p, br=TRUE)
+ hwrite(1:6, p, table=FALSE)
+ ## closePage(p)",df)
+ df=appendExample('name','Names the HTML element for further reference using hyperlinks.',
+ "## p=openPage('test.html')
+ hwrite(hwrite('Section 1.', name='s1'), p, heading=3)
+ hwrite(c('Go to this ', hwrite('section', link='#s1'), ' or this ', hwrite('one', link='#s2'), '.'), p, table=FALSE)
+ hwrite(hwrite('Section 2.', name='s2'), p, heading=3)
+ hwrite('Another section...', p)
+ ## closePage(p)",df)
+ df=appendExample('link','Adds hyperlink(s) (anchor, hypertext) to the HTML element.',
+ "hwrite('The fox', @test, link='http://www.fox.com')",df)
+ df=appendExample('div','Places the HTML element into a div HTML section, using the $<div$> HTML tag. This is helpful for styling a section.',
+ "## p=openPage('test.html', link.css='hwriter.css')
+ hwrite('In Greek mythology, a cyclops is a member of...', p, div=TRUE, class='king')
+ ## closePage(p)",df)
+ df=appendExample('center','Centers the HTML element. This element may interfere with the current CSS style. Please consider the CSS style attribute \"text-align\" instead.',
+ "## p=openPage('test.html')
+ hwrite('The fox', p, center=TRUE)
+ hwrite('jumps over the...', p, center=TRUE)
+ ## closePage(p)",df)
+ df=appendExample('...','Additional arguments are added to the HTML element as HTML attributes. For HTML tables, attributes are distributed on table cells using R recycling rules. For text elements, a $<span$> HTML tag (or $<div$> 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 <a href='http://www.w3schools.com/css'>W3C reference</a> or this <a href='http://www.somacon.com/p334.php'>wizard</a> to generate new styles.
+ By default, the style is changed on the fragment of a sentence, using the $<span$> 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 $<table$> 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.",'')
+}
diff --git a/R/hwriter.R b/R/hwriter.R
new file mode 100644
index 0000000..0607bdb
--- /dev/null
+++ b/R/hwriter.R
@@ -0,0 +1,152 @@
+hwrite=function(x,page=NULL,...)
+ UseMethod('hwrite')
+
+hwrite.character=function(x,...)
+ hwrite.vector(x,...)
+
+hwrite.numeric=function(x,...)
+ hwrite.vector(x,...)
+
+hwrite.array=function(x,...)
+ hwrite.table(x,...)
+
+hwrite.matrix=function(x,...)
+ hwrite.table(x,...)
+
+hwrite.data.frame=function(x,...)
+ hwrite.table(as.matrix(x),...)
+
+## switch between hwriteString and hwrite.matrix
+## redimension 'dim' and 'byrow' matrix orientation
+hwrite.vector=function(data,page=NULL,...,table=NULL,names=NULL,byrow=NULL,dim=NULL) {
+ ## default arguments
+ if (is.null(table)) {
+ if (length(data)<=1) table=FALSE
+ else table=TRUE
+ }
+ if (is.null(names)) names=TRUE
+ if (is.null(byrow)) byrow=FALSE
+
+ if (table) {
+ if (is.null(dim)) dim=c(1,length(data))
+ datanames=names(data)
+ data=matrix(data,nrow=dim[1],ncol=dim[2],byrow=byrow)
+ mode(data)='character'
+ ## preserve names, if possible
+ if (names) {
+ if (dim[1]==length(datanames)) rownames(data)=datanames
+ if (dim[2]==length(datanames)) colnames(data)=datanames
+ }
+ hwrite.matrix(data,page=page,...)
+ } else hwriteString(data,page=page,...)
+}
+
+## private
+## final string writing function
+hwriteString=function(txt,page=NULL,...,link=NULL,name=NULL,heading=NULL,center=NULL,br=NULL,div=NULL) {
+ ## default arguments
+ if (is.null(br)) br=FALSE
+ if (is.null(center)) center=FALSE
+ if (is.null(div)) div=FALSE
+ args=list(...)
+
+ ## box text with:
+ ## - 'a' if link is non-null or name is non-null
+ ## - 'h*' if heading is non-null
+ ## - 'div' if div is TRUE
+ ## - 'span' if args are present
+ ## - no box otherwise
+ ##
+ ## also: removes <a> tags if corresponding href and argument values are NA
+ boxtag=NULL
+ if (!is.null(link)) {
+ args=c(args, list(href=link))
+ boxtag = rep('a', length(link))
+ boxtag[is.na(link)] = NA
+ }
+ else if (!is.null(name)) {
+ args=c(args, list(name=name))
+ boxtag = rep('a', length(name))
+ boxtag[is.na(name)] = NA
+ }
+ else if (!is.null(heading)) boxtag=paste('h',heading,sep='')
+ else if (div) boxtag='div'
+ else if (length(args)>0) boxtag='span'
+
+ ## box text
+ if (!is.null(boxtag)) txt=do.call(hmakeTag,c(list(boxtag,txt),args))
+
+ ## center
+ if (center) txt=hmakeTag('center',txt)
+
+ ## line break
+ if (br) txt=paste(txt,'<br/>\n',sep='')
+
+ ## final output
+ if (is.null(page)) txt
+ else if (is.character(page)) {
+ p=openPage(page)
+ cat(txt,file=p)
+ closePage(p)
+ invisible(txt)
+ } else invisible(cat(txt,file=page))
+}
+
+hwriteImage=function(image.url,page=NULL,...,image.border=0,width=NULL,height=NULL,capture=FALSE) {
+ ## take a snapshot of the current device ?
+ if (capture) {
+ if (is.null(width)) width=400
+ if (is.null(height)) height=400
+ dev.print(png,width=width,height=height,image.url)
+ }
+ str=hmakeTag('img',border=image.border,src=image.url,alt=image.url,width=width,height=height)
+
+ ## final
+ hwrite(str,page,...)
+}
+
+resync=function() {
+ try(detach('package:hwriter'),silent=TRUE)
+ hwrite=NULL
+ source('R/hwriter.R')
+ source('R/page.R')
+ source('R/table.R')
+ source('R/example.R')
+ library(hwriter)
+}
+
+hmakeTag = function(tag, data=NULL, ..., newline=FALSE) {
+ attrs = list(...)
+
+ ## dim is the output dim of the result
+ dim = dim(tag)
+ if (!is.null(dim(data))) dim = dim(data)
+
+ if (is.null(data)) data = ''
+ na = length(attrs)
+
+ ## attributes grid
+ xattrs = NULL
+ if (na>0) {
+ namax = max(sapply(attrs, length))
+ n = max(c(length(tag), length(data), namax))
+ xattrs = matrix('', nrow=n, ncol=na)
+ nattrs = names(attrs)
+ for (i in 1:na) {
+ z = attrs[[i]]
+ if (!is.null(z)) {
+ fna = !is.na(z)
+ xattrs[fna,i] = paste(' ',nattrs[i], '=\"', z[fna], '\"', sep='')
+ if (!is.null(dim(z))) dim = dim(z)
+ }
+ }
+ xattrs = apply(xattrs, 1, paste, collapse='')
+ }
+
+ if (newline) nl = '\n' else nl = NULL
+ res = paste('<', tag, xattrs, '>', nl, data, '</', tag, '>', nl, sep='')
+ natag = rep(is.na(tag), length(res)/length(tag))
+ res[natag] = paste(rep('', length(tag)), rep('', length(xattrs)), data, sep='')[natag]
+ if (!is.null(dim)) res = array(res, dim=dim)
+ res
+}
diff --git a/R/page.R b/R/page.R
new file mode 100644
index 0000000..e945dd0
--- /dev/null
+++ b/R/page.R
@@ -0,0 +1,36 @@
+## 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 = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\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('</body>', bodyStart)-1)
+ hwrite(paste(doctype, "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='", lang, "' lang='", lang, "'>", 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<br/><br/><font size=\"-2\">(Page generated on ', date(), ' by ', hwriterlink, ' ', getHwriterVersion(), ')</font>', sep=''), page, br=TRUE)
+ else hwrite('\n<br/><br/>', page, br=TRUE)
+ hwrite('</body></html>', page, br=FALSE)
+ close(page)
+}
diff --git a/R/table.R b/R/table.R
new file mode 100644
index 0000000..db7125d
--- /dev/null
+++ b/R/table.R
@@ -0,0 +1,269 @@
+## private
+## process .row or .col argument on its corresponding rcdata matrix
+## location rule:
+## - if rowcol named, expand it to dim(data)[kaxis], with first '' to headers
+## - if rowcol unnamed of size 1, apply to header
+## fill rule:
+## - start at first data (not full) cell, if possible
+## - recycle is TRUE by default
+hprocessRowCol=function(rowcol,rcdata,data,axis,ddim,recycle=TRUE) {
+ if (!is.null(rowcol)) {
+ dim=dim(data)
+ if (axis==2) ndata=rownames(data)
+ else ndata=colnames(data)
+ kaxis=3-axis
+
+ ## named case
+ nrowcol=names(rowcol)
+ if (!is.null(nrowcol)) {
+ if (is.null(ndata)) ndata=c('',rep(NA,dim[kaxis]-1))
+ rowcol=rowcol[match(ndata,nrowcol)]
+ if (is.list(rowcol)) rowcol=lapply(rowcol,function(z) if (is.null(z)) NA else z)
+ } else {
+ ## special rules to save room for the header:
+ ## - if rowcol has more than one element
+ ## - AND if one row/col has been added in the contraxis
+ ## - AND if length rowcol is different from the contraxis
+ if (length(rowcol)!=1 & dim[kaxis]!=ddim[kaxis] & length(rowcol)!=dim[kaxis]) rowcol=c(NA,rowcol)
+ }
+
+ for (i in 1:length(rowcol)) {
+ rc=rowcol[[i]]
+ if (!all(is.na(rc))) {
+ if (recycle) rc=array(rc,dim=c(1,max(ddim[axis],length(rc))))
+ drc=length(rc)
+ j=ifelse(dim[axis]==drc,1,dim[axis]-ddim[axis]+1)
+ if (axis==1) rcdata[j:(drc+j-1),i]=rc
+ else rcdata[i,j:(drc+j-1)]=rc
+ }
+ }
+ }
+ rcdata
+}
+
+## private
+## reindex row or col named vector into a numeric fashion
+hmapRowCol=function(x,rowcolnames) {
+ if (is.null(x)) y=NULL
+ else {
+ if (is.null(names(x))) y=x
+ else {
+ if (is.null(rowcolnames)) y=NULL
+ else {
+ z=match(names(x),rowcolnames)
+ y=rep(NA,length(rowcolnames))
+ y[na.omit(z)]=x[which(!is.na(z))]
+ }
+ }
+ }
+
+ y
+}
+
+## handles row, col and table arguments
+hwrite.table=function(data,page=NULL,...,table=TRUE,row.names=T,col.names=T,split.maxncol=NULL,split.maxnrow=NULL,col.width=NULL) {
+ ddim=dim(data)
+
+ if (!table) {
+ z=hwrite(as.vector(data),table=FALSE,...)
+ dim(z)=ddim
+ return(z)
+ }
+
+ ## process row and column names (add a col and a row, resp.)
+ acol=row.names & !is.null(rownames(data))
+ arow=col.names & !is.null(colnames(data))
+ if (acol) data=cbind(rownames(data),data)
+ if (arow) data=rbind(colnames(data),data)
+
+ ## ddim is the data dim only (without extra col and/or row)
+ ## dim is the expanded data
+ dim=dim(data)
+
+ ## filters arguments
+ args=list(...)
+ nargs=names(args)
+
+ ## table arguments
+ itable=match(substr(nargs,1,6),'table.')
+ iptable=match(nargs,c('cellspacing','cellpadding','width','border'))
+ args.table=args[!is.na(itable)]
+ names(args.table)=substr(names(args.table),7,nchar(names(args.table)))
+ args.table=c(args.table,args[!is.na(iptable)])
+
+ ## row arguments
+ irow=match(substr(nargs,1,4),'row.')
+ args.row=args[!is.na(irow)]
+ names(args.row)=substr(names(args.row),5,nchar(names(args.row)))
+
+ ## col arguments
+ icol=match(substr(nargs,1,4),'col.')
+ args.col=args[!is.na(icol)]
+ names(args.col)=substr(names(args.col),5,nchar(names(args.col)))
+
+ ## string arguments
+ istring=match(nargs,c('name','heading','center','div','br'))
+ args.string=args[!is.na(istring)]
+
+ ## td arguments (remaining ones)
+ args.td=args[is.na(itable) & is.na(irow) & is.na(icol) & is.na(istring) & is.na(iptable)]
+ zargs=rep(list(NULL),length(args.row)+length(args.col))
+ names(zargs)=c(names(args.row),names(args.col))
+ args.td=c(args.td,zargs)
+
+ ## expand if needed
+ args.td=lapply(args.td,hexpand,dim,ddim)
+
+ ## process .row and .cow arguments
+ for (z in names(args.col)) args.td[[z]]=hprocessRowCol(args.col[[z]],args.td[[z]],data,1,ddim)
+ for (z in names(args.row)) args.td[[z]]=hprocessRowCol(args.row[[z]],args.td[[z]],data,2,ddim)
+
+ ## special case for col.width
+ if (!is.null(col.width)) {
+ width=array(NA,dim=dim)
+ icol.width=hmapRowCol(col.width,colnames(data))
+ width[1,1:length(icol.width)]= icol.width
+ args.td=c(args.td,list(width=width))
+ }
+
+ ## process split.maxncol and split.maxnrow
+ if (!is.null(split.maxncol) | !is.null(split.maxnrow)) {
+ if (!is.null(split.maxncol) & !is.null(split.maxnrow)) stop('either \'split.maxnrow\' or \'split.maxncol\' must be NULL')
+
+ ## split ancillary tables
+ data=hsplitArray(data,maxnrow=split.maxnrow,maxncol=split.maxncol,preserve.size=T,output.list=F,arow=arow,acol=acol)
+ for (z in names(args.td)) args.td[[z]]=hsplitArray(args.td[[z]],maxnrow=split.maxnrow,maxncol=split.maxncol,preserve.size=T,output.list=F,arow=arow,acol=acol)
+ }
+
+ do.call(hwriteRawTable,c(list(data,page=page,args.td=args.td,args.table=args.table,args.string=args.string)))
+}
+
+## private
+## expands a to be of size ddb (if possible) and put in a matrix
+## of size db, adding top/left NA rows/columns if needed
+hexpand=function(a,db,ddb) {
+ if (is.null(a)) a=NA
+ if (is.null(dim(a))) a=array(a,dim=ddb)
+ da=dim(a)
+ b=array(NA,dim=db)
+ i=ifelse(db[1]==da[1],1,db[1]-ddb[1]+1)
+ j=ifelse(db[2]==da[2],1,db[2]-ddb[2]+1)
+ b[i:(da[1]+i-1),j:(da[2]+j-1)]=a
+ b
+}
+
+## private
+hwriteRawTable=function(data,page=NULL,args.td=NULL,args.table=NULL,args.string=NULL) {
+ ## default arguments
+ if (is.null(args.table[['border']])) args.table[['border']]=1
+
+ if (!is.matrix(data)) stop('\'data\' must be a matrix')
+ dim=dim(data)
+ data=as.vector(data)
+ data[is.na(data)]=' '
+
+ ## process cell links
+ data=hwrite(data,link=args.td$link,table=F)
+ args.td$link=NULL
+
+ ## process cells
+ data=do.call(hmakeTag,c(list('td',data),args.td))
+
+ ## process rows tr
+ dim(data)=dim
+ data=apply(data,1,function(z) paste(z,collapse=''))
+ data=hmakeTag('tr',data,newline=T)
+
+ ## process table
+ data=paste(data,collapse='')
+ str=do.call(hmakeTag,c(list('table',data,newline=T),args.table))
+
+ ## final
+ do.call(hwrite,c(list(str,page),args.string))
+}
+
+## private
+## - split an array into a list of subarrays
+## - rownames and colnames are ignored
+## - arow and acol indicate that the first row (resp col) should be treated as a rowname (resp colname)
+hsplitArray=function(data,maxnrow=0,maxncol=0,preserve.size=T,output.list=T,arow=F,acol=F) {
+ if (is.null(data)) return(NULL)
+ if (!is.matrix(data)) stop('\'data\' must be a matrix')
+ if (is.null(maxnrow)) maxnrow=0
+ if (is.null(maxncol)) maxncol=0
+ if (maxnrow==0 && maxncol==0) stop('splitting must be done in one direction: either \'maxnrow\' or \'maxncol\' must be non null')
+ if (maxnrow*maxncol!=0) stop('splitting cannot be done on both directions: either \'maxnrow\' or \'maxncol\' must be null')
+ if (!output.list && !preserve.size) stop('outputting matrix is possible only if \'preserve.size\' is TRUE')
+
+ ## preserve first row (resp col)
+ if (arow) {
+ zrow=data[1,]
+ data=data[-1,]
+ }
+ if (acol) {
+ zcol=data[,1]
+ data=data[,-1]
+ }
+
+ nr=nrow(data)
+ nc=ncol(data)
+ if (output.list) out=list()
+ else out=NULL
+
+ ## maxncol splitting (horizontal splitting)
+ if (maxncol>0) {
+ nc2=maxncol
+ z1=1
+ repeat {
+ if (z1>nc) break
+ z2=z1+nc2-1
+ if (z2>nc) z2=nc
+ if (preserve.size) {
+ napz=nc2-z2+z1-1
+ zdata=matrix(c(data[,z1:z2],rep(NA,nr*napz)),nrow=nr,ncol=nc2)
+ nap=rep(NA,napz)
+ } else {
+ zdata=matrix(data[,z1:z2],nrow=nr,ncol=1+z2-z1)
+ nap=NULL
+ }
+
+ if (acol&arow) {
+ zdata=cbind(zcol,zdata)
+ zdata=rbind(c(zrow[c(1,1+(z1:z2))],nap),zdata)
+ }
+ else if (acol) zdata=cbind(zcol,zdata)
+ else if (arow) zdata=rbind(c(zrow[z1:z2],nap),zdata)
+
+ if (output.list) out=c(out,list(zdata))
+ else out=rbind(out,zdata)
+ z1=z2+1
+ }
+ }
+
+ ## maxnrow splitting (vertical splitting)
+ if (maxnrow>0) {
+ nr2=maxnrow
+ z1=1
+ repeat {
+ if (z1>nr) break
+ z2=z1+nr2-1
+ if (z2>nr) z2=nr
+ if (preserve.size) {
+ napz=nr2-z2+z1-1
+ zdata=matrix(c(t(data[z1:z2,]),rep(NA,nc*napz)),nrow=nr2,ncol=nc,byrow=T)
+ nap=rep(NA,napz)
+ } else {
+ zdata=matrix(data[z1:z2,],nrow=1+z2-z1,ncol=nc)
+ nap=NULL
+ }
+ if (acol) zdata=cbind(c(zcol[z1:z2],nap),zdata)
+ if (arow) zdata=rbind(zrow,zdata)
+
+ if (output.list) out=c(out,list(zdata))
+ else out=cbind(out,zdata)
+ z1=z2+1
+ }
+ }
+
+ out
+}
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..821433d
--- /dev/null
+++ b/TODO
@@ -0,0 +1,7 @@
+TODO:
+- lists
+- split.table, split.table.args
+- <th> headings, <caption> tag
+- FIX: col.width doesn't work if nothing is present on the first row
+- FIX: split.max.x require a matrix for link even if data is a 1-row vector
+- icolwidth logic to be synced with rowcol logic
diff --git a/build/vignette.rds b/build/vignette.rds
new file mode 100644
index 0000000..2a2be7d
Binary files /dev/null and b/build/vignette.rds differ
diff --git a/debian/README.test b/debian/README.test
deleted file mode 100644
index 55a9142..0000000
--- a/debian/README.test
+++ /dev/null
@@ -1,8 +0,0 @@
-Notes on how this package can be tested.
-────────────────────────────────────────
-
-To run the unit tests provided by the package you can do
-
- sh run-unit-test
-
-in this directory.
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644
index d450031..0000000
--- a/debian/changelog
+++ /dev/null
@@ -1,13 +0,0 @@
-r-cran-hwriter (1.3.2-1) unstable; urgency=medium
-
- * New upstream version
- * autopkgtest based on vignetes
- * cme fix dpkg-control
-
- -- Andreas Tille <tille at debian.org> Mon, 22 Sep 2014 21:41:06 +0200
-
-r-cran-hwriter (1.3-1) unstable; urgency=low
-
- * Initial release (closes: #728740)
-
- -- Andreas Tille <tille at debian.org> Mon, 04 Nov 2013 21:42:29 +0100
diff --git a/debian/compat b/debian/compat
deleted file mode 100644
index ec63514..0000000
--- a/debian/compat
+++ /dev/null
@@ -1 +0,0 @@
-9
diff --git a/debian/control b/debian/control
deleted file mode 100644
index f41028a..0000000
--- a/debian/control
+++ /dev/null
@@ -1,28 +0,0 @@
-Source: r-cran-hwriter
-Maintainer: Debian Med Packaging Team <debian-med-packaging at lists.alioth.debian.org>
-Uploaders: Andreas Tille <tille at debian.org>
-Section: gnu-r
-Priority: optional
-Build-Depends: debhelper (>= 9),
- cdbs,
- r-base-dev
-Standards-Version: 3.9.6
-Vcs-Browser: http://anonscm.debian.org/viewvc/debian-med/trunk/packages/R/r-cran-hwriter/trunk/
-Vcs-Svn: svn://anonscm.debian.org/debian-med/trunk/packages/R/r-cran-hwriter/trunk/
-Homepage: http://cran.r-project.org/web/packages/hwriter
-
-Package: r-cran-hwriter
-Architecture: all
-Depends: ${R:Depends}
-Description: HTML Writer - Outputs R objects in HTML format
- The GNU R package hwriter provides an easy-to-use and versatile
- functions to output R objects in HTML format. It supports advanced
- formatting, tables, CSS styling, images and provides a convenient
- mapping between R tables and HTML tables.
- .
- The package provides the following functions (but most of the job is
- carried out by hwrite):
- hwrite: outputs an R object in HTML format.
- hwriteImage: writes an image.
- openPage, closePage: handles HTML page/document creation.
- hmakeTag: is a low-level HTML tag formatting function.
diff --git a/debian/copyright b/debian/copyright
deleted file mode 100644
index 590ffef..0000000
--- a/debian/copyright
+++ /dev/null
@@ -1,31 +0,0 @@
-Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
-Upstream-Name: hwriter
-Upstream-Contact: Gregoire Pau <gregoire.pau at ebi.ac.uk>
-Source: http://cran.r-project.org/web/packages/hwriter
-
-Files: *
-Copyright: 2005-2010 Gregoire Pau <gregoire.pau at ebi.ac.uk>
-License: LGPL-2.1
-
-Files: debian/*
-Copyright: 2013 Andreas Tille <tille at debian.org>
-License: LGPL-2.1
-
-License: LGPL-2.1
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
- .
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
- .
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- .
- On Debian systems, the complete text of the GNU Lesser General Public
- License can be found in `/usr/share/common-licenses/LGPL-2.1'.
-
diff --git a/debian/docs b/debian/docs
deleted file mode 100644
index 9a4f4f8..0000000
--- a/debian/docs
+++ /dev/null
@@ -1,2 +0,0 @@
-debian/README.test
-debian/tests/run-unit-test
diff --git a/debian/examples b/debian/examples
deleted file mode 100644
index 18244c8..0000000
--- a/debian/examples
+++ /dev/null
@@ -1 +0,0 @@
-vignettes
diff --git a/debian/lintian-overrides b/debian/lintian-overrides
deleted file mode 100644
index cea01b6..0000000
--- a/debian/lintian-overrides
+++ /dev/null
@@ -1,2 +0,0 @@
-# All R-modules are ending up in /usr/lib - so there is no real point in moving small images around
-r-cran-hwriter: image-file-in-usr-lib usr/lib/R/site-library/hwriter/images/*
diff --git a/debian/rules b/debian/rules
deleted file mode 100755
index 2fbba2d..0000000
--- a/debian/rules
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/make -f
-
-include /usr/share/R/debian/r-cran.mk
diff --git a/debian/source/format b/debian/source/format
deleted file mode 100644
index 163aaf8..0000000
--- a/debian/source/format
+++ /dev/null
@@ -1 +0,0 @@
-3.0 (quilt)
diff --git a/debian/tests/control b/debian/tests/control
deleted file mode 100644
index d2aa55a..0000000
--- a/debian/tests/control
+++ /dev/null
@@ -1,3 +0,0 @@
-Tests: run-unit-test
-Depends: @
-Restrictions: allow-stderr
diff --git a/debian/tests/run-unit-test b/debian/tests/run-unit-test
deleted file mode 100644
index d20ba13..0000000
--- a/debian/tests/run-unit-test
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh -e
-oname=hwriter
-pkg=r-cran-`echo $oname | tr [A-Z] [a-z]`
-
-if [ "$ADTTMP" = "" ] ; then
- ADTTMP=`mktemp -d /tmp/${pkg}-test.XXXXXX`
-fi
-cd $ADTTMP
-cp /usr/share/doc/$pkg/examples/vignettes/* $ADTTMP
-find . -name "*.gz" -exec gunzip \{\} \;
-for rnw in `ls *.[rR]nw` ; do
-rfile=`echo $rnw | sed 's/\.[rR]nw/.R/'`
-R --no-save <<EOT
- Stangle("$rnw")
- source("$rfile", echo=TRUE)
-EOT
-done
-rm -rf *
diff --git a/debian/watch b/debian/watch
deleted file mode 100644
index 1e69b90..0000000
--- a/debian/watch
+++ /dev/null
@@ -1,2 +0,0 @@
-version=3
-http://cran.r-project.org/src/contrib/hwriter_([-\d.]*)\.tar\.gz
diff --git a/inst/doc/hwriter.R b/inst/doc/hwriter.R
new file mode 100644
index 0000000..f37ee9e
--- /dev/null
+++ b/inst/doc/hwriter.R
@@ -0,0 +1,9 @@
+### R code from vignette source 'hwriter.Rnw'
+
+###################################################
+### code chunk number 1: example
+###################################################
+library('hwriter')
+example('hwriter')
+
+
diff --git a/inst/doc/hwriter.Rnw b/inst/doc/hwriter.Rnw
new file mode 100644
index 0000000..78a7893
--- /dev/null
+++ b/inst/doc/hwriter.Rnw
@@ -0,0 +1,56 @@
+% \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.
+
+%
+<<example>>=
+library('hwriter')
+example('hwriter')
+@
+%
+
+\end{document}
+
diff --git a/inst/doc/hwriter.pdf b/inst/doc/hwriter.pdf
new file mode 100644
index 0000000..e4585e2
Binary files /dev/null and b/inst/doc/hwriter.pdf differ
diff --git a/inst/images/hwriter.css b/inst/images/hwriter.css
new file mode 100644
index 0000000..84a55c4
--- /dev/null
+++ b/inst/images/hwriter.css
@@ -0,0 +1,49 @@
+body {
+ padding-top: 10px; padding-left: 5%; padding-right: 5%;
+ font-family: Palatino;
+ background-color: #ffffff
+}
+
+table {
+ border-collapse: collapse;
+ margin-left: auto;
+ margin-right: auto;
+ background-color: #f6f6f6;
+ border-color: gray
+}
+
+table td {
+ padding-top: 5px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px;
+ border-color: gray
+}
+
+.intro {
+ background-color: #fff4f4;
+ border: 1px solid;
+ padding: 10px
+}
+
+.textbox {
+ text-align: left;
+ background-color: #c0c0ff;
+ padding: 5%;
+ margin-left:30px;
+ margin-right:30px
+}
+
+a.example:link {color: black; text-decoration: none; border: solid black 1px; padding:4px; background: white}
+a.example:visited {color: black; text-decoration: none; border: solid black 1px; padding:4px; background: white}
+a.example:hover {background:#ffdc98}
+
+a.example2:link {color: black; text-decoration: none; border: solid black 1px; padding:4px; background: white}
+a.example2:visited {color: black; text-decoration: none; border: solid black 1px; padding:4px; background: white}
+a.example2:hover {background:#c0c0ff}
+
+.king {
+ margin-left: 10px; margin-top:4px; margin-bottom:4px;
+ padding-left: 10px; padding-top: 3px; padding-bottom: 3px;
+ background-color: white;
+ border: solid 1px black;
+ font-style: italic;
+ text-align: left
+}
diff --git a/inst/images/iris1.jpg b/inst/images/iris1.jpg
new file mode 100644
index 0000000..24fd752
Binary files /dev/null and b/inst/images/iris1.jpg differ
diff --git a/inst/images/iris2.jpg b/inst/images/iris2.jpg
new file mode 100644
index 0000000..854e3e2
Binary files /dev/null and b/inst/images/iris2.jpg differ
diff --git a/inst/images/iris3.jpg b/inst/images/iris3.jpg
new file mode 100644
index 0000000..c01a804
Binary files /dev/null and b/inst/images/iris3.jpg differ
diff --git a/inst/images/motif.png b/inst/images/motif.png
new file mode 100644
index 0000000..4f307a0
Binary files /dev/null and b/inst/images/motif.png differ
diff --git a/inst/scripts/build.sh b/inst/scripts/build.sh
new file mode 100755
index 0000000..ab06895
--- /dev/null
+++ b/inst/scripts/build.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+rm -rf hwriter.Rcheck .Rhistory ..Rcheck example-hwriter.html inst/doc/hwriter.pdf hwriter*.tar.gz article
+
+R CMD build .
+R CMD check hwriter*.tar.gz
+rm -rf hwriter.Rcheck
+
+R CMD INSTALL .
+echo "library(hwriter) ; example(hwriter) ; file.copy(file.path(tempdir(),'example-hwriter.html'),'.',overwrite=TRUE)" | R --no-save --vanilla
+
+scp -P 6422 hwriter_1.2.tar.gz gpau at localhost:~/public_html/hwriter
+scp -P 6422 example-hwriter.html gpau at localhost:~/public_html/hwriter/index.html
+
+rm -rf hwriter.Rcheck .Rhistory ..Rcheck inst/doc/hwriter.pdf
diff --git a/man/hmakeTag.Rd b/man/hmakeTag.Rd
new file mode 100644
index 0000000..e5fc71d
--- /dev/null
+++ b/man/hmakeTag.Rd
@@ -0,0 +1,55 @@
+\name{hmakeTag}
+
+\alias{hmakeTag}
+
+\title{HTML/XML tag formatter}
+
+\description{
+ Formats an HTML/XML tag, using a low-level syntax.
+}
+
+\usage{
+hmakeTag(tag, data=NULL, ..., newline=FALSE)
+}
+
+\arguments{
+ \item{tag}{a character vector or matrix containing the HTML/XML tags.}
+
+ \item{data}{a character vector or matrix containing the tag bodies.}
+
+ \item{newline}{a logical. Appends a newline \code{\\n} character at the end of the tags.}
+
+ \item{...}{optional attributes that will be appended to the tags.}
+}
+
+\value{
+ A character vector or matrix, containing the output HTML/XML tags.
+}
+
+\details{
+ This low-level function is used by \code{hwrite} to build HTML tags.
+ This function is useful to build non-standard or rare HTML tags.
+}
+
+\seealso{
+ \code{\link{hwrite}}.
+}
+
+\examples{
+## simple call
+hmakeTag('a','Centipede',href='http://en.wikipedia.org/wiki/Centipede')
+
+## vectorized calls
+hmakeTag('tag',1:10,color='red')
+hmakeTag(colors()[1:10],1:10,semantic='color')
+
+## nested calls
+hmakeTag('html',hmakeTag('body','Text'),'xml:lang'='en')
+}
+
+\author{
+ Gregoire Pau, \email{gpau at ebi.ac.uk}, 2008
+}
+
+\keyword{interface}
+
diff --git a/man/hwrite.Rd b/man/hwrite.Rd
new file mode 100644
index 0000000..9a476ab
--- /dev/null
+++ b/man/hwrite.Rd
@@ -0,0 +1,132 @@
+\name{hwrite}
+
+\alias{hwrite}
+
+\title{HTML writer}
+
+\description{
+ Outputs an R object in HTML format.
+}
+
+\usage{
+ hwrite(x, page=NULL, ...)
+}
+
+\arguments{
+ \item{x}{an R object to output in HTML format. Objects of type \code{character}, \code{vector}, \code{matrix}
+ and \code{data.frame} are currently supported. }
+
+ \item{page}{an optional connection, a character string naming the file to write
+ to or a page object returned by \code{openPage}.}
+
+ \item{...}{optional arguments. See Details.}
+}
+
+\value{
+ A character vector containing the output HTML code.
+}
+
+\details{
+ If \code{x} is a vector of only one element, it will be written by default
+ as an HTML text element unless \code{table} is \code{TRUE}: in that case,
+ it will be written as an HTML table containing an unique element.
+
+ If \code{x} is a vector of more than one element, a matrix or a data.frame, it will be
+ written by default as an HTML table unless \code{table} is \code{FALSE}: in that case,
+ it will be written as a vector or a matrix of HTML text elements.
+
+ Many optional arguments can be used to render an HTML object. See below for
+ additional information. Many comprehensive examples can be found in the
+ Examples section by typing \code{example(hwrite)}.
+}
+
+\section{General arguments}{
+ The following optional arguments can always be used:
+ \describe{
+ \item{br}{a logical specifying if a breakline (carriage return) should
+ be appended at the end of \code{x}. Default is \code{FALSE}.}
+
+ \item{table}{a logical controlling if the object \code{x} should be written as an HTML table. Default is \code{TRUE} for matrices and vectors containing more than one element, and \code{FALSE} otherwise. If set to \code{FALSE}, the object is written as a vector (or a matrix) of HTML text elements.}
+
+ \item{link}{a character vector containing the URLs the HTML element
+ will point to. This argument is the equivalent of the attribute \code{href} of the HTML tag <a>.}
+
+ \item{name}{a character string naming the HTML element for further reference. This is the equivalent of the attribute \code{name} of the HTML tag <a>.}
+
+ \item{div}{a logical. If \code{TRUE}, places the HTML element into a HTML section, using the <div> HTML tag. This is helpful for styling a section. Default is \code{FALSE}.}
+
+ \item{center}{a logical indicating if \code{x} should be centered. Default is \code{FALSE}. This element may interfere with the current CSS style. Please consider the use the CSS style attribute "text-align" instead.}
+
+ \item{...}{Additional arguments are added to the HTML element as HTML attributes. For HTML tables, attributes are distributed on table cells using R recycling rules. For text elements, a <span> HTML tag (or <div> if \code{div} is \code{TRUE}) is used to accommodate the attributes.}
+ }
+}
+
+\section{Additional arguments for text elements}{
+ If \code{x} is rendered as an HTML text element, the following optional arguments can be used:
+
+ \describe{
+ \item{heading}{a numeric containing the heading level style. Valid values spans from 1 to 5. See Examples.}
+ }
+}
+
+\section{Additional arguments for vectors}{
+ If \code{x} is a vector with more than one element, the following optional
+ arguments can be used:
+
+ \describe{
+ \item{dim}{a couple of optional numeric values indicating the desired number of rows
+ and columns in the table. This is useful to orient a vector.}
+
+ \item{byrow}{logical. If \code{TRUE}, the table is filled by
+ rows first, otherwise the table is filled by columns first. Default is \code{FALSE}.}
+
+ \item{names}{a logical indicating if the names of the elements should
+ be written if the vector is named. Default is \code{TRUE}.}
+ }
+}
+
+\section{Additional arguments for tables}{
+ If \code{x} is rendered as an HTML table element, the following optional arguments can be used:
+
+ \describe{
+ \item{border}{a numeric. 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.}
+
+ \item{row.names, col.names}{a logical value indicating whether the row (resp. column) names of
+ \code{x} are to be written. Default is \code{TRUE}.}
+
+ \item{cellspacing, cellpadding}{a numeric. Defines the spacing and padding space in pixels between cells. These arguments may interfere with the "border" and "padding" CSS style attributes.}
+
+ \item{width}{a character string. Specifies the global table width in HTML units (pixels or \%).}
+
+ \item{col.width}{a named character vector. Specifies the columns width
+ in HTML units (pixels or \%) where names of \code{col.width} are used to
+ point column names of \code{x}. NAs may be used to let several column
+ widths unspecified.}
+
+ \item{row.*, col.*}{a list of character vectors or a character vector. Distributes the attribute '*' on the HTML table cells, according to rows (resp. columns).
+ 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 pointed rows/columns sizes don't match, vector values are recycled using R rules.}
+
+ \item{table.*}{a character string. Uses the global table attribute '*' to render the HTML table. The attribute is added to the main <table> tag. Some uses include
+ setting of the "border" and "margin" CSS attributes that cannot be distributed on cells.}
+
+ \item{*}{a character string, vector or matrix. Distributes the attribute '*' on the HTML table cells, using R recycling rules.
+ Any valid HTML attributes can be used. The value may contain NAs to omit cells. Matrices may contain one extra row and/or column to target heading cells.}
+ }
+
+ See Examples for many illustrated examples of all arguments.
+}
+
+\seealso{
+ \code{\link{openPage}}, \code{\link{closePage}}, \code{\link{hwriteImage}}, \code{\link{hmakeTag}}.
+}
+
+\examples{
+ hwriter:::showExample()
+}
+
+\author{
+ Gregoire Pau, \email{gpau at ebi.ac.uk}, 2008
+}
+
+\keyword{interface}
diff --git a/man/hwriteImage.Rd b/man/hwriteImage.Rd
new file mode 100644
index 0000000..d822c4b
--- /dev/null
+++ b/man/hwriteImage.Rd
@@ -0,0 +1,82 @@
+\name{hwriteImage}
+
+\alias{hwriteImage}
+
+\title{Insert an HTML image}
+
+\description{
+ Inserts one or several images in an HTML document. The images can be either
+ external ones specified by URL or file path, or captured from the current
+ graphic device.
+}
+
+\usage{
+hwriteImage(image.url, page=NULL, ..., image.border=0, width=NULL,
+height=NULL, capture=FALSE)
+}
+
+\arguments{
+ \item{image.url}{a character vector or matrix containing the URL or the file path of images.}
+
+ \item{page}{an optional connection, a character string naming the file to write
+ to or a page object returned by \code{openPage}.}
+
+ \item{image.border}{an optional numeric value specifiying the width of the image border.
+Default is 0.}
+
+ \item{width, height}{an optional HTML length unit (in pixels) specifiying the width (resp. height) at which the image
+ should be rendered. If missing, the default image width
+ (resp. height) will be used.}
+
+ \item{capture}{a logical. If \code{TRUE} the image from the current
+ graphic device is captured and written as a PNG file to the filename specified by
+ \code{image.url}. Capture resolution is controlled by \code{width}
+ and \code{height}, which have a default value of 400 pixels. Default is \code{FALSE}.}
+
+ \item{...}{optional arguments that will be dispatched to the
+ underlying \code{hwrite} call.}
+}
+
+\value{
+ A character vector containing the output HTML code.
+}
+
+\details{
+ \code{hwriteImage} constructs an HTML <img> tag to insert one or several images. This function can be seamlessly in conjuction with \code{hwrite}
+to position an image. The \code{capture} argument enables to capture
+easily a current plot and to insert it in a web page.
+
+By default, if \code{image.url} is a vector the output value will be a
+character string containing the HTML code of a table containing the
+images. This behaviour is dictated by the underlying \code{hwrite} call
+made by \code{hwriteImage}. The argument \code{table} can be set to
+\code{TRUE} to obtain a vector of HTML image tags instead.
+}
+
+\seealso{
+ \code{\link{hwrite}}.
+}
+
+\examples{
+## Creates a new web page 'test.html'
+tmpdir <- tempdir()
+p <- openPage('test.html', dirname=tmpdir)
+
+## Insert an external image
+img <- hwriteImage('http://www.ebi.ac.uk/~gpau/hwriter/iris1.jpg', center=TRUE)
+hwrite(c(img,caption='Iris'), p, dim=c(2,1),
+row.style=list(caption='text-align:center;background-color:#fac'),
+row.names=FALSE, br=TRUE)
+
+## Closes the web page
+closePage(p)
+
+## Opens a web browser to see the result
+if (interactive()) try(browseURL(file.path(tmpdir, 'test.html')))
+}
+
+\author{
+ Gregoire Pau, \email{gpau at ebi.ac.uk}, 2008
+}
+
+\keyword{interface}
diff --git a/man/hwriter-package.Rd b/man/hwriter-package.Rd
new file mode 100644
index 0000000..fb93865
--- /dev/null
+++ b/man/hwriter-package.Rd
@@ -0,0 +1,44 @@
+\name{hwriter-package}
+
+\alias{hwriter}
+\docType{package}
+
+\title{HTML writer}
+
+\description{
+ \code{hwriter} is an easy-to-use package able to format and
+ output R objects in HTML format. It supports advanced formatting,
+ tables, CSS styling, Javascript, images and provides a convenient mapping between
+ R tables and HTML tables. \code{hwriter} generates XHTML 1.0 transitional
+ HTML code.
+
+ See Examples and \code{hwrite} for more details.
+
+ The project page is \url{http://www.ebi.ac.uk/~gpau/hwriter}.
+}
+
+\section{Package content}{
+ \code{hwriter} provides the following functions (but most of the job is
+ carried out by \code{hwrite}):
+ \itemize{
+ \item \code{hwrite} outputs an R object in HTML format.
+ \item \code{hwriteImage} writes an image.
+ \item \code{openPage}, \code{closePage} handles HTML page/document
+ creation.
+ \item \code{hmakeTag} is a low-level HTML tag formatting function.
+ }
+}
+
+\seealso{
+ \code{\link{hwrite}}, \code{\link{hwriteImage}}, \code{\link{openPage}}, \code{\link{closePage}}, \code{\link{hmakeTag}}.
+}
+
+\examples{
+ hwriter:::showExample()
+}
+
+\author{
+ Gregoire Pau, \email{gpau at ebi.ac.uk}, 2008
+}
+
+\keyword{interface}
diff --git a/man/openPage.Rd b/man/openPage.Rd
new file mode 100644
index 0000000..8c4f0fd
--- /dev/null
+++ b/man/openPage.Rd
@@ -0,0 +1,102 @@
+\name{openPage}
+
+\alias{openPage}
+\alias{closePage}
+
+\title{HTML document/page management}
+
+\description{
+ Opens and closes an HTML page/document, allowing a sequential building
+ of an HTML page.
+}
+
+\usage{
+openPage(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)
+
+closePage(page, splash=TRUE)
+}
+
+\arguments{
+ \item{filename}{a character string containing the filename or the path
+ of the HTML file to be created.}
+
+ \item{dirname}{an optional character string containing the path of the
+ directory where the file should be written.}
+
+ \item{title}{an optional character string containing the title of the
+ HTML page.}
+
+ \item{link.javascript}{an optional character vector containing the URL of Javascripts
+ to be associated with the page.}
+
+ \item{link.css}{an optional character vector containing the URL of CSS stylesheets
+ to be associated with the page.}
+
+ \item{css}{an optional character vector containing inline CSS stylesheets to be associated with the page.}
+
+ \item{head}{an optional character string containing an HTML fragment
+ to be added in the <head> section of the page.}
+
+ \item{charset}{an optional character string containing the current charset. Default is "utf-8".}
+
+ \item{lang}{an optional character string containing the current
+ langage. Default is "en".}
+
+ \item{head.attributes}{an optional named list of character strings,
+ containing the <head> attributes.}
+
+ \item{body.attributes}{an optional named list of character strings,
+ containing the <body> attributes.}
+
+ \item{page}{a page handle returned by a previous \code{openPage}
+ call.}
+
+ \item{splash}{a logical, indicating whether the hwriter splash tag
+ 'generated by...' should be written at the end of the page.}
+
+}
+
+\value{
+ A connection which is a handle to the current HTML page.
+}
+
+\details{
+ \code{openPage} opens a new file for writing and returns a page handle
+ which is used by \code{hwrite} to append HTML elements in a current
+ page. Any previous existing file will be overwritten.
+
+ The argument \code{head} is useful to add extra HTML code in the <head> header code.
+
+ \code{closePage} ends the HTML page formatting, flushes the pending
+writing operations and closes the file.
+}
+
+\seealso{
+ \code{\link{hwrite}}, \code{\link{hmakeTag}}.
+}
+
+\examples{
+## Creates a new web page 'test.html' in the R temporary directory
+tmpdir <- tempdir()
+p <- openPage('test.html', dirname=tmpdir,
+ link.css='http://www.ebi.ac.uk/~gpau/hwriter/hwriter.css')
+hwrite('Iris example', p, center=TRUE, heading=1)
+hwrite(paste('This famous (Fisher\'s or Anderson\'s) iris data set',
+ 'gives the measurements in centimeters of the variables',
+ 'sepal length and width and petal length and width, respectively,',
+ 'for 50 flowers from each of 3 species of iris.'),
+ p, class='king')
+hwrite(iris, p, row.bgcolor='#ffffaa')
+closePage(p)
+
+## Opens a web browser on the web page
+if (interactive()) try(browseURL(file.path(tmpdir, 'test.html')))
+}
+
+\author{
+ Gregoire Pau, \email{gpau at ebi.ac.uk}, 2008
+}
+
+\keyword{interface}
diff --git a/vignettes/hwriter.Rnw b/vignettes/hwriter.Rnw
new file mode 100644
index 0000000..78a7893
--- /dev/null
+++ b/vignettes/hwriter.Rnw
@@ -0,0 +1,56 @@
+% \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.
+
+%
+<<example>>=
+library('hwriter')
+example('hwriter')
+@
+%
+
+\end{document}
+
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/r-cran-hwriter.git
More information about the debian-med-commit
mailing list