Creates a report shell to which you may add titles, footnotes, content, etc.
create_report( file_path = "", output_type = "TXT", orientation = "landscape", units = "inches", paper_size = "letter", missing = "" )
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 write the report. In addition,
the file extension is not required. If the file extension is not supplied,
the |
---|---|
output_type | The report output type. Default is "TXT". Valid values are "TXT", "RTF", and "PDF". |
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 |
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. |
A new report_spec object.
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.
The report is the primary container for report specifications. The
following functions add additional specifications to the report object
initialized with create_report
.
titles
to add titles to the report.
footnotes
to add footnotes to the report.
title_header
to add a title header to the report.
page_header
to add a page header to the report.
page_footer
to add a page_footer to the report.
add_content
to add content to the report.
options_fixed
to set options for fixed-width output.
add_content
to add content to the report.
write_report
to write the report to the file system.
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.
Note that PDF output has some limitations not found in TXT and RTF output. See NotesOnPDF for additional information.
create_table
, create_text
, and
create_plot
functions
to create content for the report.
Other report:
add_content()
,
footnotes()
,
options_fixed()
,
page_by()
,
page_footer()
,
page_header()
,
print.report_spec()
,
set_margins()
,
title_header()
,
titles()
,
write_report()
library(reporter) library(magrittr) # Create temp file path tmp <- file.path(tempdir(), "airquality.txt") # Prepare Data dat <- airquality[sample(1:153, 15), ] dat$Month <- as.Date(paste0("1973-", dat$Month, "-01")) # Define table tbl <- create_table(dat, show_cols = c("Month", "Day", "Wind", "Temp", "Ozone")) %>% titles("Table 9.6", "Air Quality Sample Report") %>% column_defaults(width = .5) %>% define(Month, format = "%B", align = "left", width = 1) %>% define(Temp, format = "%.0f") %>% footnotes("* New York, May to September 1973") # Define report rpt <- create_report(tmp, orientation = "portrait", missing = "-") %>% add_content(tbl) # Write the report to the file system write_report(rpt) # Write the report to the console writeLines(readLines(tmp, encoding = "UTF-8")) # Table 9.6 # Air Quality Sample Report # # Month Day Wind Temp Ozone # ---------------------------------------- # July 8 6.3 92 97 # July 9 5.7 92 97 # August 1 6.9 81 39 # July 23 11.5 82 - # June 9 13.8 90 71 # July 12 14.3 73 10 # July 4 10.9 84 - # May 31 7.4 76 37 # September 30 11.5 68 20 # June 25 8 75 - # June 28 11.5 80 - # August 18 7.4 76 23 # June 20 10.3 76 13 # July 1 4.1 84 135 # May 23 9.7 61 4 # # * New York, May to September 1973