Package 'htmlreportR'

Title: 'HTML' Reporting Made Simple(R)
Description: Create compressed, interactive 'HTML' (Hypertext Markup Language) reports with embedded 'Python' code, custom 'JS' ('JavaScript') and 'CSS' (Cascading Style Sheets), and wrappers for 'CanvasXpress' plots, networks and more. Based on <https://pypi.org/project/py-report-html/>, its sister project.
Authors: Álvaro Esteban Martos [aut, cph, cre] , José Córdoba Caballero [aut, cph] , James Perkins [aut, cph] , Pedro Seoane Zonjic [aut, cph] , Jesús Pérez García [aut, cph]
Maintainer: Álvaro Esteban Martos <[email protected]>
License: GPL (>= 3)
Version: 1.0.1
Built: 2025-02-16 06:02:12 UTC
Source: https://github.com/aestebanmar/htmlreportr

Help Index


.prepare_standard_triplet_df

Description

Build triplet data frame for make_html_list function from three vectors. User should NEVER have to worry about this function

Usage

.prepare_standard_triplet_df(
  list_content,
  list_levels = NULL,
  list_types = NULL,
  default_type = "ul"
)

Arguments

list_content

Vector or list of elements with which to build the list

list_levels

Vector or list defining nesting levels. Default NULL

list_types

Vector or list with types to assign to each element ("ul" for unordered or "ol" for ordered).' If not supplied, default_type will determine list type for each element. Default NULL

default_type

List type to default if list_types is undefined, "ul" for unordered or "ol" for ordered. Default "ul"

Value

Data frame of contents, levels and types, ready for make_html_list.


Add Header and Row Names to Data Frame for HTML Report table

Description

This function modifies a data frame to include specific column and row names.

Arguments

data_frame

The data frame to be modified.

options

A list of options controlling the modification of column and row names.

Details

Add Header and Row Names to Data Frame for HTML Report table

This function checks the options provided and manipulates the column and row names of the input data frame accordingly. If the 'header' option is set to true, it assigns the first row of the data frame as column names and removes that row from the data frame. If the 'row_names' option is true, it assigns the first column of the data frame as row names and removes that column from the data frame. If either option is not true, it assigns sequential numbers as column or row names, respectively.

Value

The modified data frame with updated column and/or row names.


Build CanvasXpress barplot from R data frame

Description

Loads data frame and CanvasXpress options for barplot, then calls canvasXpress_main to build it.

Arguments

options

list with options.

Details

CanvasXpress barplot

Value

HTML code for CanvasXpress bar plot of data.


Build HTML Report Body

Description

This method builds the body of an HTML report by appending the specified body text to an htmlReport object.

Arguments

body_text

A character string containing the body text to be appended to the HTML report.

Details

Build HTML Report Body

Value

An updated htmlReport object with the specified body text appended to its body.


Build HTML report from template

Description

This function builds an HTML report from a given template file for an object of class "htmlReport".

Arguments

template

A character string specifying the file path of the template.

Details

Build HTML report from template

This function reads the contents of the template file, sets up Knitr options for rendering, renders the template using Knitr, and constructs the HTML report by combining the rendered template with the existing report content in the "htmlReport" object.

Value

A new instance of the htmlreportR class


encode and compress data json

Description

compress_data

Arguments

data

string indicating object id

Value

encoded and compressed json


Custom addition operator for combining htmlReport objects

Description

This function defines a custom addition operator for combining two strings.

Arguments

value

An object of any type that can be coerced to character.

Details

Custom addition operator for combining htmlReport objects

Value

An object of class "htmlReport" with an updated @all_report which includes at the end the "value" string.


Build CanvasXpress density plot from R data frame

Description

Loads data frame and CanvasXpress options for density plot, then calls canvasXpress_main to build it.

Arguments

options

list with options.

Details

CanvasXpress density plot

Value

HTML code for CanvasXpress density plot of data.


Retrieve Data from htmlReport Object

Description

This method retrieves data from an htmlReport object based on specified options.

Arguments

options

A list containing options for data retrieval.

Details

Retrieve Data from htmlReport Object

Value

A list containing the retrieved data and additional information.


Retrieve Data from htmlReport Object

Description

This method retrieves data from an htmlReport object based on specified options.

Arguments

options

A list containing options for data retrieval.

Value

A list containing the retrieved data and additional information.


Get Data for Plotting from htmlReport Object

Description

This method retrieves data suitable for plotting from an htmlReport object based on specified options.

Arguments

options

A list containing options for data retrieval.

Details

Get Data for Plotting from htmlReport Object

Value

A list containing the retrieved data, attributes, samples, and variables.


Get Plot from htmlReport Object

Description

This method generates and retrieves a plot from an htmlReport object. This code writes the plot to a temporal png, then it loads the png in base64 encoding and then displays the plot within the HTML report.

Arguments

plot_obj

A plot object like ggplot.

width

plot width

height

plot height

size_unit

units in plot size

img_properties

string including html properties of img

resizable

logical indicating if plot must be resizable

Details

Get Plot from htmlReport Object

Value

Displays the plot within the HTML report.


Get js Plot from canvasxpress_obj Object

Description

get_plot_data

Arguments

object_id

string indicating object id

cvXpress

vanvasXpress_obj object

Value

Displays the js code for plot.


Build CanvasXpress line plot from R data frame

Description

Loads data frame and CanvasXpress options for line plot, then calls canvasXpress_main to build it.

Arguments

options

list with options.

Details

CanvasXpress line plot

Value

HTML code for CanvasXpress line plot of data.


Build report by loading files from disk and rendering template.

Description

Main htmlreportR script mode function. Renders a template,

Usage

main_htmlreportR(options)

Arguments

options

list containing all necessary elements to build an htmlReport instance.

Details

Main htmlreportR scripting function

Value

None

Examples

## Not run: 
options <- list(title = "main_htmlreportR example",
			   data_files = "path/to/file1", "path/to/fileN",
			   output_file = "path/to/output",
			   source_folder = "path/to/package/scripts",
			   compress_obj = TRUE,
			   css_files = "path/to/custom/css",
			   js_files = "path/to/custom/js",
			   cdn_css = "path/to/cdn_css",
			   cdn_js = "path/to/cdn_js",
			   menu = "menu")
main_htmlreportR (options)

## End(Not run)

Make HTML Report Head

Description

This method generates the head section of an HTML report by adding the title to an htmlReport object.

Details

Make HTML Report Head

Value

An updated htmlReport object with the title added to its head section.


make_html_list

Description

Take an input vector or list and use it to build an html list of specified type

Usage

make_html_list(
  list_content,
  list_levels = NULL,
  list_types = NULL,
  default_type = "ul"
)

Arguments

list_content

Vector or list of elements with which to build the list

list_levels

Vector or list defining nesting levels. Default NULL

list_types

Vector or list with types to assign to each element ("ul" for unordered or "ol" for ordered).' If not supplied, default_type will determine list type for each element. Default NULL

default_type

List type to default if list_types is undefined, "ul" for unordered or "ol" for ordered. Default "ul"

Value

Formatted html list ready to render.


Merge tables from multiple hash_vars ids

Description

Non-exported method that will be called by extract_data if it is provided with multiple ids.

Arguments

options

A list containing options for data retrieval.

Details

Merge tables contained in hash_vars

Value

A merged data frame, minus specified fields and rows.


Print data frame in HTML format

Description

Parses a data frame included in an object of class "htmlReport" and HTML table to include it in htmlreportR

Arguments

data_frame

Data frame to parse

options

list with options

table_id

An integer. Table id in report

row_names

A boolean.

  • TRUE (the default): Parse data frame row names as a column of the HTML table.

  • FALSE (the default): Do not parse data frame row names.

Details

Parse data frame to HTML

Value

A table in html format.


Encapsulates input code in div of specified characteristics

Description

pretiffy_div

Arguments

data

string indicating object id

Value

encoded and compressed json


replace_paired_mark

Description

Recursively replaces paired marks in a string.

Usage

replace_paired_mark(string, pattern, replace)

Arguments

string

String to edit

pattern

Pattern to recursively replace

replace

Vector containing, in that order, expression that will replace the first paired element and the second paired element

Value

Modified string.


Build CanvasXpress scatter2D plot from R data frame

Description

Loads data frame and CanvasXpress options for scatter2D plot, then calls canvasXpress_main to build it.

Arguments

options

list with options.

Details

CanvasXpress scatter2D plot

Value

HTML code for CanvasXpress scatter2D plot of data.


Generate static ggplot for HTML report

Description

This function generates a static ggplot for inclusion in an HTML report for an object of class "htmlReport".

Arguments

id

A character string specifying the identifier for the element of hash_vars that is taken.

header

Logical, indicating whether the dataset has a header row.

row_names

Logical, indicating whether to include row names.

transpose

Logical, indicating whether to transpose the dataset.

smp_attr

A list of attributes for samples.

var_attr

A list of attributes for variables.

fields

A character vector specifying fields to include in the ggplot.

func

A function to preprocess data before plotting.

plotting_function

A function used for generating the ggplot.

text

Logical, indicating whether to convert table to text or a vector indicating the numeric fields.

width

plot width

height

plot height

size_unit

units in plot size

img_properties

string including html properties of img

resizable

logical indicating if plot must be resizable

Details

Generate static ggplot for HTML report

This function generates a static ggplot based on the provided data and plot specifications. It first defines a wrapper function for ggplot generation, then calls the static_plot_main function to generate the plot and include it in the HTML report object.


Generate static plot for HTML report

Description

This function generates a static plot for inclusion in an HTML report for an object of class "htmlReport".

Arguments

id

A character string specifying the identifier for the plot included in hash_vars.

header

Logical, indicating whether the dataset has a header row.

row_names

Logical, indicating whether to include row names.

transpose

Logical, indicating whether to transpose the dataset.

smp_attr

A list of attributes for samples.

var_attr

A list of attributes for variables.

fields

A character vector specifying the fields to include in the plot.

func

A function to preprocess data before plotting.

plotting_function

A function used for generating the plot.

text

Logical, indicating whether to convert table to text or a vector indicating the numeric fields.

custom_format

Logical, indicating if id correspond to a table or a custom object

width

plot width

height

plot height

size_unit

units in plot size

img_properties

string including html properties of img

resizable

logical indicating if plot must be resizable

classic_R_plot

logical indicating if is using classic plot() R function

Details

Generate static plot for HTML report

This function generates a static plot based on the provided data and plot specifications. It first retrieves the data frame for plotting using the provided options, preprocesses the data if a preprocessing function is specified, generates the plot using the provided plotting function, and then adds the plot to the HTML report object.


Generate table from plotter object with specified options

Description

This method takes a list of options to build a table from a htmlReport object.

Arguments

options

list with options

Details

Table method for htmlReport class

Value

A string encoding a html table.


Write HTML Report

Description

This method writes the HTML report generated by an htmlReport object to a specified output file path.

Arguments

output_path

A character string specifying the output file path for the HTML report.

Details

Write HTML Report

Value

Writes the HTML report to the specified output file path and removes temporary files.