write_report: Write a report to the file system

Description Usage Arguments Details Value See Also Examples

View source: R/report_spec.r

Description

This function writes a report_spec object to the file system, using the specifications provided in the object.

Usage

1

Arguments

x

The report object to write.

Details

The function renders the report in the requested format, and writes it to the location specified in the report file_path parameter. Attempts to write an object that is not of class "report_spec" will generate an error.

The write_report function is a driver for very complex set of rendering functions. The rendering functions perform most of the advanced functionality of the rptr package: generating spanning headers, page wrapping and breaking, creating stub columns, etc. When things go wrong, they will usually go wrong during this function call. For that reason, although this function can be part of the pipeline that creates the report object, it is best to call write_report independently, to help isolate any issues from the report definition procedure.

Value

The report spec, with settings modified during rendering. These modified settings can sometimes be useful for documentation, and for debugging issues with the procedure.

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
library(rptr)
library(magrittr)

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

# Create the table
tbl <- create_table(mtcars) %>% 
  titles("Table 1.0", "MTCARS Sample Report") %>% 
  footnotes("* NOTE: Data from 1974")

# Create the report object
rpt <- create_report(tmp) %>% 
  add_content(tbl, align = "left") 

# Write the report to the file system
res <- write_report(rpt)

# Write the modified report object to the console
print(res)

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

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