write_idea.Rd
This function allows the user to write IDEA4 results either as local PNG files or compiled in reports.
write_idea( IDEA_plots, output_directory = "IDEATools_output", type = c("local", "report"), prefix = NULL, dpi = 320, report_format = "docx", append = FALSE, input_file_append = NULL, quiet = FALSE )
IDEA_plots | an IDEA_plots or IDEA_group_plots object from a |
---|---|
output_directory | the desired output directory for the rendered reports and/or plots. Defaults to "IDEATools_output" |
type | the type of output to produce. Can be either "report" to produce compiled reports or "local" to write raw plots as PNG files. |
prefix | a prefix which will be added to output files names. Typically, the name of the farm. Ignored in the case of a group analysis : The |
dpi | ggplot output resolution. |
report_format | a string indicating the output format if |
append | If the input is an xlsx format, should the individual output be appended to the original file ? |
input_file_append | file path to an xslx IDEA data spreadsheet |
quiet | A command to remove console printing. |
Reports and/or raw plots in output_directory
.
This function automatically creates in output_directory
a subdirectory named after the system date for users to use the same output_directory for multiple diagnosis.
Inputs of class IDEA_plots
can be generated by a classic read_idea() %>% compute_idea() %>% plot_idea()
or old_idea() %>% plot_idea()
individual analysis pipelines. Inputs of class IDEA_group_plots
can only be generated by a plot_idea()
call in a group analysis conducted by diag_idea
.
In the case of an individual analysis, another subdirectory is created with prefix
as a name so that analyses are not mixed up. The user can choose if output should be raw plots (that can be used in custom reports) or pre-compiled reports with a large variety of available formats.
In the case of a group analysis, another subdirectory is created with a name like "Groupe_number_of_farms" so that analyses are not mixed up. The user can again choose if output should be raw plots or pre-compiled reports.
If the report_format
argument is set to either "docx", "odt" or "pptx", the report will be rendered using the rmarkdown package (and officedown/officer packages for the docx output) using a template stored in this package. For "html" and "pdf" output, the pagedown package will be used to produce a clean paged HTML report using CSS files stored in this package, which can be converted to PDF using chrome print. For "xlsx" output, the openxlsx package will be used to sequentially produce Excel worksheets and files, using an internal R function.
Please note that an error will be produced if the input object does not contain all three "dimensions","trees" and "radars" entries in the case of an individual analysis and if type = "report"
.
library(IDEATools) path <- system.file("idea_example.json", package = "IDEATools") my_data <- read_idea(path) computed_data <- compute_idea(my_data) idea_plots <- plot_idea(computed_data) if (FALSE) { # Find your temporary directory tempdir <- tempdir() # Export as raw plots to your tempdir. write_idea(idea_plots, output_directory = tempdir, type = "local", prefix = "myFarm", dpi = 300 ) # Export as xlsx reports to your tempdir. write_idea(idea_plots, output_directory = tempdir, prefix = "myFarm", type = "report", dpi = 300, report_format = c("pdf", "xlsx") ) }