create_report: Create a report

Description Usage Arguments Details Value Report family of functions See Also Examples

View source: R/report_spec.r

Description

Creates a report shell to which you may add titles, footnotes, content, etc.

Usage

1
2
3
4
5
6
7
8
create_report(
  file_path = "",
  output_type = "text",
  orientation = "landscape",
  units = "inches",
  paper_size = "letter",
  missing = ""
)

Arguments

file_path

The output path of the desired report. Either a full path or a relative path is acceptable. This parameter is not required to create the report_spec object, but will be required to print the report.

output_type

The report output type. Currently, the only valid value is "text". Default is "text". Will eventually support "RTF", "PDF", and "DOCX".

orientation

The page orientation of the desired report. Valid values are "landscape" or "portrait". The default page orientation is "landscape".

units

Specifies the units of measurement. This setting will indicate the units for columns widths, margins, paper size, and other measurements. Valid values are "inches" or "cm" (centimeters). Default value is "inches".

paper_size

The expected paper size on which the report may be printed. The paper_size will determine how much text can fit on one page. Valid values are "letter", "legal", "A4", and "RD4". Default is "letter".

missing

How to display missing values in the report. Default is to replace them with an empty string, which removes them from the report. To display missing values as is, set the missing parameter to NULL. To replace missing values with a character string (such as ".", "-", or "<NA>") pass the desired character string to the missing parameter.

Details

This function is the constructor for the report object. The report object contains information needed to create a report. The object is defined as an S3 object, and has a class of 'report_spec'.

The report object holds information concerning report page size, orientation, titles, footnotes, page header, page footer, margins, and other options. Use the add_content function to add content to the report. The report may be written to a file using the write_report function.

Value

A new report_spec object.

Report family of functions

The report is the primary container for report specifications. The following functions add additional specifications to the report object initialized with create_report.

The report family of functions are pipe-friendly. After creating the report, you may pipe the object to any of the above functions to append additional options.

See Also

create_table and create_text functions to create content for the report.

Other report: add_content(), footnotes(), options_fixed(), page_footer(), page_header(), set_margins(), titles(), write_report()

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
library(rptr)
library(magrittr)

# Create temp file path
tmp <- file.path(tempdir(), "mtcars.txt")

# Create the report object
rpt <- create_report(tmp, orientation = "portrait") %>% 
  titles("MTCARS Sample Report") %>% 
  add_content(create_table(mtcars[1:10, ])) 

# Write the report to the file system
write_report(rpt)

# Write the report to the console
writeLines(readLines(tmp))

#                              MTCARS Sample Report
# 
#   mpg    cyl   disp     hp   drat     wt   qsec     vs     am   gear   carb
#  ----------------------------------------------------------------------------
#    21      6    160    110    3.9   2.62  16.46      0      1      4      4
#    21      6    160    110    3.9  2.875  17.02      0      1      4      4
#  22.8      4    108     93   3.85   2.32  18.61      1      1      4      1
#  21.4      6    258    110   3.08  3.215  19.44      1      0      3      1
#  18.7      8    360    175   3.15   3.44  17.02      0      0      3      2
#  18.1      6    225    105   2.76   3.46  20.22      1      0      3      1
#  14.3      8    360    245   3.21   3.57  15.84      0      0      3      4
#  24.4      4  146.7     62   3.69   3.19     20      1      0      4      2
#  22.8      4  140.8     95   3.92   3.15   22.9      1      0      4      2
#  19.2      6  167.6    123   3.92   3.44   18.3      1      0      4      4

dbosak01/reporter documentation built on Sept. 22, 2020, 3:34 p.m.