Skip to contents

Perform cell conditional formatting of two colours based on if a given word on a given numeric column from curve_summary.

Usage

format_num_cell_colour(
  workbook,
  sheet,
  curve_summary,
  dilution_summary = lifecycle::deprecated(),
  conditional_column,
  threshold_value,
  pass_criteria = c("above", "below"),
  pass_equality = TRUE
)

Arguments

workbook

A workbook object from openxlsx.

sheet

The name of the sheet to apply the numeric style on workbook.

curve_summary

The summary table generated by function summarise_curve_table() and/or evaluate_linearity().

dilution_summary

[Deprecated] dilution_summary was renamed to curve_summary.

conditional_column

A character vector to indicate which column in curve_summary to use.

threshold_value

The threshold value to indicate a pass or fail.

pass_criteria

To indicate pass if the value is above or below threshold value. Default: c("above", "below")

pass_equality

To indicate if equality to the threshold value is considered a pass or fail. Default: TRUE

Examples

r_corr <- c(
  0.951956, 0.948683, 0.978057, 0.976462,
  0.970618, 0.969348, 0.343838, 0.383552
)

pra_linear <- c(
  65.78711, 64.58687, 90.21257, 89.95473,
  72.91220, 72.36528, -233.05949, -172.13659
)

mandel_p_val <- c(
  2.899006e-07, 7.922290e-07, 2.903365e-01, 3.082930e-01,
  3.195779e-08, 6.366588e-08, 3.634004e-02, 1.864090e-02
)

concavity <- c(
  -4133.501328, -4146.745747, -3.350942, -3.393617,
  0.3942824, 0.4012963, -19.9469621, -22.6144875
)

curve_summary <- data.frame(
  r_corr = r_corr, pra_linear = pra_linear,
  mandel_p_val = mandel_p_val,
  concavity = concavity
)

curve_summary <- mark_near_zero_columns(curve_summary)

# Create a new workbook
my_workbook <- openxlsx::createWorkbook()

# Create a new worksheet
openxlsx::addWorksheet(wb = my_workbook, sheetName = "Curve Summary")

# Write to worksheet as an Excel Table
openxlsx::writeDataTable(
  wb = my_workbook, sheet = "Curve Summary",
  x = curve_summary,
  withFilter = TRUE,
  bandedRows = FALSE
)

# Conditional formatting can only be done
# after data is written to excel sheet
format_num_cell_colour(
  workbook = my_workbook, sheet = "Curve Summary",
  curve_summary = curve_summary,
  conditional_column = "r_corr",
  threshold_value = "0.8",
  pass_criteria = "above"
)