[R] HTML Output from R

partha_bagchi@hgsi.com partha_bagchi at hgsi.com
Mon Sep 27 14:41:32 CEST 1999


Apologies to the group for not having summarized (and taking all this time)
all the replies I got on this topic.
The original question was if anyone had done HTML output from R. The
message also included a first attempt at writing such a function..
_________

Thanks, to Terry Westley who suggested that I model the function after
write.table. I was not aware of write.table (my fault). Since then I have
looked at to see how it handles rows and columns.
Thanks to Peter Sinn who suggested I look at Rweb. Rweb uses <ver></ver> to
write output. I was looking to "pretty" up the output.
Thanks to Kurt Hornik who echoed Terry Westley's suggestions and also noted
the eventuality of HTML output or LaTeX output from write.table.
_________

Based on write.table, the solution I settled on, is as follows: (as usual,
suggestions welcomed).

write.html.table <- function(x, file= "", capt= "The Default Title", append
= FALSE){
#x the dataframe to be written to an HTML file
  head <- paste("<table border= 1, align= \"center\">\n<caption>", capt,
"</caption>\n<tr><td>\n")
  cat(head, file= file, append= append)
  write.table(x, sep= "<td>", file= file, eol= "</tr>\n", row.names= rep
("<tr>", nrow(x)),
              col.names= TRUE, append= TRUE, quote= FALSE)
  cat("</tr>\n</table>\n", file= file, append= TRUE)
}

_________

Partha Bagchi.


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list