add_cover_page: Cover page

Description Usage Arguments Examples

Description

This function generates the cover page of the report. It is fully optional to use it so just leave this function out of the code if you do not need cover page.

Usage

1
2
3
4
5
add_cover_page(..., header_color = "#f44242", footer_color = "#3d3c3c",
  creaton_time = Sys.Date(), logo = NA, logo_size = NULL,
  theme = c("basic", "flashy"), extra_layout_params = function() { },
  title = myprettyreport.env$report_title,
  subtitle = myprettyreport.env$report_subtitle)

Arguments

...

Other arguments passed on to methods. It is only for technical usage.

header_color

Character string which specifies the color of the header. Only HEX color codes are accepted (e.g. #ffffff). Default value is "#f44242".

footer_color

Character string which specifies the color of the footer. Only HEX color codes are accepted (e.g. #ffffff). Default value is "#3d3c3c".

creaton_time

Character string value which is implemented for displaying creation time of the report but it can be used for other purpose. Default value is Sys.Date().

logo

Name of the logo file which has been already loaded into R. I recommend to use image_read function from package magick to load images into R. Default value is NA which means that nothing will appear in place of the logo.

logo_size

Numeric value which specifies the size of the logo. Default value is NULL which means that the original size of the logo file will be used.

theme

Character string which specifies the theme of the report. Possible values are "basic" and "flashy". Try both themes and check the differences.

extra_layout_params

User defined grid functions can be passed in the PDF report to modify the layout region. It has to be defined as a dummy function, see the example section for more details.

title

Character string which allows to set up user defined title to a cover page. The default value is the previously defined start_report() title parameter.

subtitle

Character string which allows to set up user defined subtitle to a cover page. The default value is the previously defined start_report() subtitle parameter.

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
# minimal example
# it generates PDF file with only a cover page.
start_report() %>%
  add_cover_page() %>%
  end_report()

# change the theme of the report from default.
start_report() %>%
  add_cover_page(theme = "flashy") %>%
  end_report()

# add a logo to a report
# 1. load the logo file.
library(magick)
sample_logo <- magick::image_read("http://myhappydata.com/img/1.png")
# 2. add the loaded file to a report.
start_report() %>%
  add_cover_page(logo = sample_logo) %>%
  end_report()

# change the default colors to custom ones.
start_report() %>%
  add_cover_page(
    header_color = "#6DCFF6",
    footer_color = "#D8D3CB"
  ) %>%
  end_report()

# pass extra grid paramters into the report
cp_e_params = function() {
   grid::grid.rect(gp = grid::gpar(fill = "grey"),
                   vp = grid::viewport(layout.pos.row = 2,
                                       layout.pos.col = 1),
                   width = 0.8, height = 0.2)
   grid::grid.text("example text",
                   vp = grid::viewport(layout.pos.row = 2,
                                       layout.pos.col = 1))
}

start_report() %>%
  add_cover_page(
    extra_layout_params = cp_e_params
  ) %>%
  end_report()

tarkomatas/myprettyreport documentation built on May 9, 2019, 7:40 a.m.