Skip to content
Prev 310329 / 398506 Next

sweave xtable and driver RweaveHTML

Hi

I have sometimes had to produce an html table in Sweave for a 
complicated table and have make a chunk of it .
cut down version below.
You could use the defaults for write.table

     fhtml <-
     paste(baseRimg, "-T", ".html", sep = "")
     if (file.exists(fhtml) ) file.remove(fhtml)
     file.create(fhtml)

     # open to append
     ff <- file(fhtml, "a+")

     # Table
     fchars <-
     c(fchars,
       '<TABLE align="center" border="0">\n',
       '<CAPTION>\n',
       "Ewe numbers by date, farm and year born",
       '</CAPTION>\n')

     writeLines(fchars, ff)

     # print xtable
     fchars <-
     print(
     xtable(xx
            ),
            type    = "html",
            html.table.attributes = "border = '0'",
            include.rownames = FALSE,
            include.colnames = FALSE,
            only.contents = TRUE, #NA.string = " ",
            hline.after = NULL
     ) ## xtable

     writeLines(fchars, ff)

     # Close
     writeLines('</TABLE>\n</HTML>', ff)
     close(ff)

HTH

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mackay at northnet.com.au
At 03:10 9/11/2012, you wrote: