| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/R5.R |
| 3 |
\docType{class} |
| 4 |
\name{Pandoc-class} |
| 5 |
\alias{Pandoc-class} |
| 6 |
\alias{Pandoc} |
| 7 |
\title{Reporting with Pandoc} |
| 8 |
\arguments{ |
| 9 |
\item{...}{this is an R5 object without any direct params but it should be documented, right?} |
| 10 |
} |
| 11 |
\description{ |
| 12 |
This \code{R5} reference class can hold bunch of elements (text or R objects) from which it tries to create a Pandoc's markdown text file. Exporting the report to several formats (like: PDF, docx, odt etc. - see Pandoc's documentation) is also possible, see examples below. |
| 13 |
} |
| 14 |
\section{Methods}{ |
| 15 |
|
| 16 |
\describe{ |
| 17 |
\item{\code{export(Class)}}{Returns the result of coercing the object to |
| 18 |
Class. No effect on the object itself.} |
| 19 |
}} |
| 20 |
|
| 21 |
\examples{ |
| 22 |
\dontrun{ |
| 23 |
## Initialize a new Pandoc object |
| 24 |
myReport <- Pandoc$new() |
| 25 |
|
| 26 |
## Add author, title and date of document |
| 27 |
myReport$author <- 'Anonymous' |
| 28 |
myReport$title <- 'Demo' |
| 29 |
|
| 30 |
## Or it could be done while initializing |
| 31 |
myReport <- Pandoc$new('Anonymous', 'Demo') |
| 32 |
|
| 33 |
## Add some free text |
| 34 |
myReport$add.paragraph('Hello there, this is a really short tutorial!') |
| 35 |
|
| 36 |
## Add maybe a header for later stuff |
| 37 |
myReport$add.paragraph('# Showing some raw R objects below') |
| 38 |
|
| 39 |
## Adding a short matrix |
| 40 |
myReport$add(matrix(5,5,5)) |
| 41 |
|
| 42 |
## Or a table with even # TODO: caption |
| 43 |
myReport$add.paragraph('Hello table:') |
| 44 |
myReport$add(table(mtcars$am, mtcars$gear)) |
| 45 |
|
| 46 |
## Or a "large" data frame which barely fits on a page |
| 47 |
myReport$add(mtcars) |
| 48 |
|
| 49 |
## And a simple linear model with Anova tables |
| 50 |
ml <- with(lm(mpg ~ hp + wt), data = mtcars) |
| 51 |
myReport$add(ml) |
| 52 |
myReport$add(anova(ml)) |
| 53 |
myReport$add(aov(ml)) |
| 54 |
|
| 55 |
## And do some principal component analysis at last |
| 56 |
myReport$add(prcomp(USArrests)) |
| 57 |
|
| 58 |
## Sorry, I did not show how Pandoc deals with plots: |
| 59 |
myReport$add(plot(1:10)) # TODO: caption |
| 60 |
|
| 61 |
## Want to see the report? Just print it: |
| 62 |
myReport |
| 63 |
|
| 64 |
## Exporting to PDF (default) |
| 65 |
myReport$export() |
| 66 |
|
| 67 |
## Or to docx in tempdir: |
| 68 |
myReport$format <- 'docx' |
| 69 |
myReport$export(tempfile()) |
| 70 |
|
| 71 |
## You do not want to see the generated report after generation? |
| 72 |
myReport$export(open = FALSE) |
| 73 |
} |
| 74 |
} |