Learn R Programming

rapport (version 1.1)

rapport.export: Export rapport object

Description

This function exports rapport class objects to various formats based on the pander package.

Usage

rapport.export(
  rp = NULL,
  file,
  append = FALSE,
  create = TRUE,
  open = TRUE,
  date = pander_return(Sys.time()),
  description = TRUE,
  format = "html",
  options = "",
  logo = TRUE
)

Arguments

rp

a rapport class object or list of rapport class objects

file

filename of the generated document. Inherited from rapport class if not set. If file is set with path (not equal to getwd()), please set an absolute path for images (see: evalsOptions()).

append

FALSE (new report created) or an R object (class of "Report") to which the new report will be added

create

should export really happen? It might be handy if you want to append several reports.

open

open the exported document? Default set to TRUE.

date

character string as the date field of the report. If not set, current time will be set.

description

add Description of the rapport class (template)? Default set to TRUE.

format

format of the wanted report. See Pandoc's user manual for details. In short, choose something like: html, pdf, odt or docx.

options

options passed to Pandoc.convert.

logo

add rapport logo

Value

filepath on create = TRUE, Report class otherwise

Details

By default this function tries to export the report to HTML with pandoc. Some default styles are applied. If you do not like those default settings, use your own options argument.

Default parameters are read from global options:

  • 'rapport.user'

Please be sure to set 'rapport.user' option with options() to get your name in the head of your generated reports!

References

John MacFarlane (2012): _Pandoc User's Guide_. https://johnmacfarlane.net/pandoc/README.html

See Also

rapport.html rapport.pdf rapport.odt rapport.docx

Examples

Run this code
# NOT RUN {
## eval some template
x <- rapport('Example', data = mtcars, var="hp")

## try basic parameters
rapport.export(x)
rapport.export(x, file = 'demo')
rapport.export(x, file = 'demo', format = 'odt')

### append reports
# 1) Create a report object with the first report and do not export (optional)
report <- rapport.export(x, create = F)
# 2) Append some other reports without exporting (optional)
report <- rapport.export(x, create = F, append = report)
# 3) Export it!
rapport.export(append=report)
# 4) Export it to other formats too! (optional)
rapport.export(append=report, format='rst')

### exporting multiple reports at once
rapport.export(rapport.example('Example', 'all'))
rapport.export(rapport.example('Example', 'all'), format = 'odt')
rapport.export(list(rapport('univar-descriptive', data = mtcars, var = "hp"),
    rapport('Descriptives', data = mtcars, var = "mpg")))

### Never do this as being dumb:
rapport.export()

### Adding own custom CSS to exported HTML
rapport.export(x, options =
    sprintf('-c %s', system.file('templates/css/default.css', package='rapport')))
# }

Run the code above in your browser using DataLab