pmx_report: Generates ggpmX report from a pre-defined template

Description Usage Arguments Details Examples

View source: R/pmx-report.R

Description

Generates ggpmX report from a pre-defined template

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
pmx_report(
  contr,
  name,
  save_dir,
  format = c("both", "plots", "report"),
  template = "standing",
  footnote = format == "both",
  edit = FALSE,
  extension = NULL,
  title,
  ...
)

Arguments

contr

pmxClass controller

name

character The report name

save_dir

Output directory. A directory to write the results files to

format

character the result type, can be
a standalone directory of plots or a report document as defined in the template
(pdf, docx,..) ,or both

template

character ggPMX predefined template or the path to a custom rmarkdwon template.
Use pmx_report_template to get the list of available templates

footnote

logical TRUE to add a footnote to the generated plots. The default footnote is to add
the path where the plot is saved.

edit

logical TRUE to edit the template immediately

extension

character The output document format. By default, a word report is generated.
User can specify one or more formats from c("word","pdf","html","all"). extnestion "all" to generate all formats.

title

character report title (optional)

...

extra parameters depending in the template used

Details

pmx_report uses pre-defined template .Rmd to generate the report. The idea is to pass the controller as a report argument using knitr params artifact.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
library(ggPMX)
## list of templates
## ctr %>% pmx_report_template()

report_dir <- tempdir()
## case1: generate a single report
## We use default save dir, 
ctr <- theophylline()
ctr %>% pmx_report(
  name = "my_report",
  save_dir = report_dir,
  format="report")

## case2: generate standalone plots
## Note here the use of a custom dir to save results
ctr <- theophylline()
ctr %>% pmx_report(
  name = "my_report",
  save_dir = report_dir,
  format="plots")


## case3: generate both : reports + plots
## by default add footnote
## Note , you can force footnote to FALSE using footnote parameter
ctr <- theophylline()
ctr %>% pmx_report(
  name = "my_report",
  save_dir = report_dir,
  format="both")

## case4 : generate standalone plots with footnotes
ctr <- theophylline()
ctr %>% pmx_report(
  name = "my_report",
  save_dir = report_dir,
  footnote=TRUE,
  format="plots")





##  case6: dynamic edit
## uncomment to run 
# ctr <- theophylline()
# ctr %>% pmx_report(
#   save_dir = file.path(report_dir,"case6"),
#   name = "my_report",
#   format="report",
#   edit = TRUE)


## case7 : use custom template file 

ctr <- theophylline()
custom_template <- 
  file.path( system.file(package = "ggPMX"),"examples","templates","custom_report.Rmd")
ctr %>% pmx_report(
  name="report2",
  save_dir = report_dir,
  template=custom_template,
  format="both"
)

## case7 : generate individual plots report 

## ctr <- theophylline()
## ctr %>% pmx_report(
##   name="report2",
##   save_dir = report_dir,
##   template="individual",
##   format="both",
##   which_pages=1:2
## )

## case8: misc example with complicated features
## see github issue : #179
ctr <- theophylline()
misc_template <- 
  file.path( system.file(package = "ggPMX"),"examples","templates","misc.Rmd")
ctr %>% pmx_report(
  name="misc",
  save_dir = report_dir,
  template=misc_template,
  format="both"
)

ggPMX documentation built on Sept. 20, 2021, 5:09 p.m.