[R] newbie HWRITER package question

Gregoire Pau gregoire.pau at embl.de
Fri May 1 10:21:30 CEST 2009


Hi Tena,

To associate a CSS stylesheet to your web page with the package 
'hwriter', you just have to use the 'link.css' argument of the method 
'openPage' (as documented in ?openPage). Your example will then become:

library(hwriter)
lcss = 'http://www.ebi.ac.uk/~gpau/hwriter/hwriter.css'
p = openPage ('testPage.html', link.css=lcss)
hwrite (iris[1:3,1:3], p, row.bgcolor='#ffda99')
closePage (p)
browseURL ('testPage.html')

'lcss' could be also 'hwriter.css' if the file is in your local path.

The package 'hwriter' is also able to deal with Javascript. The 
following cool example displays an interactive HTML sortable table, 
using Javascript capabilities:

library(hwriter)
lcss = 'http://www.ebi.ac.uk/~gpau/hwriter/hwriter.css'
lj = 'http://www.kryogenix.org/code/browser/sorttable/sorttable.js'
p = openPage('test.html', link.css=lcss, link.javascript=lj)
hwrite(iris, p, table.class='sortable', row.bgcolor='#fff4f4')
closePage(p)
browseURL('test.html')

Hope this helps,
Best regards,

Greg
-- 
Gregoire Pau
EMBL Research officer
http://www.ebi.ac.uk/~gpau/

Tena Sakai wrote:
> Hi,
> 
>> How can I get R to insert such line into the head section
>> of html file being generated under hwriter?
> 
> I found an answer myself.  It turns out that the line
>   <link rel="stylesheet" type="text/css" href="hwriter.css"></link>
> doesn't have to go into body section.  As an experiment, I did:
> 
>   p = openPage ('testPage.html')
>   hwrite ('<link rel="stylesheet" type="text/css" href="hwriter.css"></link>', p)
>   hwrite (iris[1:3,1:3], p, row.bgcolor='#ffda99')
>   closePage (p)
>   
>   browseURL ('testPage.html')
> 
> and I get what I wanted.
> If you have a better/different idea, I'd love to hear it.
> 
> Regards,
> 
> Tena Sakai
> tsakai at gallo.ucsf.edu
> 
> 
> -----Original Message-----
> From: r-help-bounces at r-project.org on behalf of Tena Sakai
> Sent: Thu 4/30/2009 3:56 PM
> To: r-help at r-project.org
> Subject: [R] newbie HWRITER package question
>  
> Hi,
> 
> I am playing with hwriter examples given in "example" page.
> Here's what I've done:
> 
>> library (hwriter)
>>
>> p = openPage ('table.html')
>> hwrite (1:5, p)
>> hwrite (iris[1:3, 1:3], p, row.bgcolor='#ffdc98')
>> closePage (p)
>>
>> browseURL('table.html')
> 
> What I get is not as nice as what I see via the "example"
> page.  I looked at the html source for the example page
> and got a notion maybe I should stick this line between
> <head> and </head>:
>   <link rel="stylesheet" type="text/css" href="hwriter.css"></link>
> (I had copied this file into the current working directory.)
> and bingo!  Yeeehaa!  My page suddenly looks so much nicer!
> 
> So, here's today's newbie quesion:
> 
> How can I get R to insert such line into the head section
> of html file being generated under hwriter?
> 
> I would appreciate your guidance.
> 
> Thank you.
> 
> Regards,
> 
> Tena Sakai
> tsakai at gallo.ucsf.edu
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list