Below are some frequently asked questions about the reporter package. Click on the links below to navigate to the full question and answer content.
Q: I can see from the examples that the reporter package can create text reports. Can it create any other types of reports? PDF? DOCX?
A: The reporter package supports TXT, RTF, PDF, HTML, and DOCX output types.
Q: I see a lot of Courier font in the examples. Does reporter support any other fonts?
A: The supported fonts depend on the output type
selected. Obviously for TXT reports, no fonts are supported.
The RTF, PDF, HTML, and DOCX output types support Courier, Arial, and
Times New Roman.
Q: The examples show little in the way of styling: fonts, colors, bolding, etc. What options are there for adding styles to the report?
A: Styles and themes are now available for the HTML output type. Take a look at the styles vignette for more information about this exciting new feature.
For all other output types, the titles()
function has
parameters to bold the title block, and set the font size independently
of the main report. Styling such as that for HTML will become available
for other output types in the near future.
Q: All of the examples I saw show a landscape page orientation. Is there a way to have a portrait page orientation?
A: Yes. The orientation
parameter on
the create_report()
function accepts both “landscape” and
“portrait” values.
Q: All of the examples I saw show column widths specified in inches. Is there a way to specify them in metric? What about by percentage?
A: The units
parameter on the
create_report()
function allows you to control the units of
measure. Valid values are “inches” and “cm” for centimeters. The
parameter accepts no other value. The issue of setting column widths by
percentage has been raised, and is under consideration as a future
enhancement.
Note that this parameter sets the units of measure for every
measurement on the report, not just column widths. The units for
margins, table width, plot width, etc. will all be understood to be in
the units specified on the units
parameter. In other words,
the whole report will be in either inches or centimeters. You cannot mix
measurement systems on a report.
Q: With SAS® proc report, I can add statistics to my report. Does the reporter package have any statistical capabilities?
A: No. The focus of the reporter package is on creating a printable report in multiple output types. There are many R packages to generate statistics. If you want statistics in your report, run your desired statistical functions, and add the result to the input data.
Q: With SAS® proc report, I can group my data in the reporting procedure. Does the reporter package have grouping capabilities?
A: No. There are already several ways to group data
in R. It is best to group data with one of the existing functions before
sending into the reporter package. Note that group rows
can be emphasized on the report using the dedupe
,
blank_after
, and label_row
parameters on the
define()
function. See example 2 and example 3 from the vignettes for a
demonstration on how to use these parameters.
Q: I have some data to report on, but it is not sorted the way I want for reporting. Does reporter have any way to sort the data?
A: No. There are many ways to sort data in R. It is therefore recommended to sort the data before sending it into the reporter package.
Generally speaking, the input data should be fully prepared for reporting. The reporter package will take your input data pretty much as-is and create a report in the desired output file format. Any data manipulation should be done prior to reporting.
Q: I have some data to report on, but it is not filtered the way I want. Does reporter have any way to filter the data?
A: No. There are many ways to filter data in R. It is therefore recommended to filter the data before sending it into the reporter package.
Q: I want to add some superscripts and subscripts to my report. Does reporter have a way to do that?
A: Yes. The reporting functions recognize Unicode superscript and subscript characters. These characters may be entered as a 4-digit Unicode code. For instance, the code “\U00B2” specifies a superscript two. See the superscript and subscript vignette for further explanation on this topic.
Q: I have some data to report on, but it has more columns than I want to show in the report. Does reporter have any way to remove some columns from the report?
A: Yes. There are two ways to remove a column from
the report. The first is to use the show_cols
parameter on
the create_table()
function. This parameter accepts a
vector of column names to include on the table.
The second way is to use the visible
parameter on the
define()
function. Setting this parameter to FALSE will
hide that variable on the report.
Q: The variables in my data are not ordered exactly as I want them to appear on the report. Is there a way to control column order?
A: Generally it is better to prepare your input data
so that everything is ordered the way you want prior to reporting. But
there is a way to order the columns if they are not in the desired
order. You can use the show_cols
parameter on the
create_table()
function to do this. Simply pass a vector of
column names to the show_cols
parameter, and put the column
names in the order you want them to appear on the report.
Note that if you are using define()
functions, the order
of these functions have no affect on the order of columns on the
report.
Q: I have variable in my input data that is not formatted. I want to apply a format to it; say, round to 1 decimal place and add a percent sign. Is there a way to format a variable?
A: Yes. You can use the format
parameter on the define()
function to identify a format for
a variable. The format passed to this parameter should be a valid format
for the fapply()
function from the fmtr package. See
the fapply()
documentation for additional information.
Q: Overall, the reporter package does a good job of determining when to break to the next page. However, sometimes I want to control exactly when the page break occurs. Is there a way to do that?
A: Yes. You can add a variable to your input data
that has the desired page number for each row. Then use the
page_break
parameter on the define()
function
to identify that variable as a page break variable. The package will
then use that variable to break pages, instead of the automatic paging
variable.
You can also set the number of lines on a page using the
line_count
parameter on the options_fixed()
function. When this parameter is set, it will use the number of lines
specified to determine when to break a page, instead of using the
automatically calculated value.
Q: Overall, the reporter package does a good job of determining when to wrap a page when it is too wide. However, sometimes I want to control exactly when the page wrap occurs. Is there a way to do that?
A: Yes. You can use the page_wrap
parameter on the define()
function to identify a variable
to wrap on. See example 6 in the
documentation for an illustration of how to wrap pages.
Q: I see there are several ways to set column widths. However, I just want to set the width of the entire table, and have reporter figure out the column widths proportionally. Is there a way to do that?
A: Yes. You can use the width
parameter
on the create_table()
function to set a width for the
entire table. The width should be specified in the units identified on
the units
parameter on the create_report()
function. See the create_table()
function documentation for
more information on the width
parameter.
Q: I’m trying to use curly braces in my footnotes. For some reason, I keep getting an error. Why?
A: The curly braces are delimiter characters for the glue function, which is automatically run on titles, footnotes, and labels. You can use the curly braces to reference a variable or run a function from within string. To avoid the error, you can escape the glue functionality by doubling the curly braces. In other words, use “{{mystring}}” instead of “{mystring}.
You can also turn off the glue functionality globally by setting
globals("reporter.glue" = FALSE)
.