Set height and width for all the plots in `create_report()` of the `DataExplorer` package in `R`

27 views Asked by At

A simple call to the create_report() function from the DataExplorer package for R

create_report(
    data=<DATA>,
    output_file='report.html',
    y='DepVariable',
    report_title='My Simple Report'
)

generates plots that are simply too big. How can this be reset globally?

A package template sets these options globally - see here

1

There are 1 answers

0
stefan On

As the figure width and height are hardcoded in the template the only way I see to achieve your desired result would be to create a custom template, i.e. download the default template, set your desired width and height (e.g. I used fig.width = 5 and fig.height = 4) and instead of using create_report use rmarkdown::render to render your report based on the custom template.

Note: When using create_report the Rmd uses the package namespace as the environment. Instead, when using rmarkdown::render we have to attach networkD3 and ggplot2 manually using library(). (But of course could you add these to the custom template file as well.)

library(DataExplorer)
library(networkD3)
library(ggplot2)

rmarkdown::render(
  "report.Rmd",
  params = list(
    data = data.table::data.table(mtcars),
    report_config = configure_report(),
    set_title = "Data Profiling Report",
    response = NULL
  ),
  output_format = rmarkdown::html_document(
    toc = TRUE, toc_depth = 6,
    theme = "yeti"
  ),
  output_dir = getwd(),
  intermediates_dir = getwd()
)

enter image description here