Skip to content

Instantly share code, notes, and snippets.

@nassimhaddad
Created February 7, 2013 12:01
Show Gist options
  • Save nassimhaddad/4730506 to your computer and use it in GitHub Desktop.
Save nassimhaddad/4730506 to your computer and use it in GitHub Desktop.
generate html code with R
library(R2HTML)
# setup a temporaty file to store the code
fileName <- 'temp.html'
.HTML.file = file.path(getwd(), fileName)
# make a title
HTML(as.title("Title of my report"), append = FALSE)
# add space
HTMLhr()
# add text
HTML("3 dimensions identity matrix")
# add a matrix
HTML(diag(3))
# add a matrix with internal border formatting
# note: more info about formatting: ?HTML.data.frame
HTML(diag(3), innerBorder = 1)
# get the html code into a variable
hrml_code_chunk <- readChar(fileName, file.info(fileName)$size)
# clean up
file.remove(fileName)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment