Code
install.packages(c("ivdtools", "rmarkdown", "knitr"))This document explains how to set up the ivdtools analysis environment, create an R Markdown project, import and validate data, run a progressive analysis, and save reproducible results.
ivdtools 0.1.1 requires R >= 4.1.0. It is recommended to use a still-supported newer R version and to keep the same major version and dependency versions across all people in the project.
Download the installer for your system from CRAN: https://cran.r-project.org/.
The base R can be installed from the system repository:
sudo apt update
sudo apt install r-base r-base-devsudo dnf install R R-develThe R version in Linux distribution repositories may be older; if the project needs a newer R, configure the software source according to the CRAN instructions for the corresponding distribution.
It is recommended to use .Rmd or .qmd files to record code, text, tables, and figures.
| Software | Windows | Linux | macOS | Suitable for |
|---|---|---|---|---|
| RStudio | ✓ | ✓ | ✓ | Works out of the box; suitable for beginners and routine analysis |
| Positron | ✓ | ✓ | ✓ | Suitable for users who want the new-generation Posit IDE |
| Visual Studio Code | ✓ | ✓ | ✓ | Requires configuring R, Quarto and other extensions |
| Jupyter | ✓ | ✓ | ✓ | Requires Python, Jupyter and an R kernel |
| PyCharm | ✓ | ✓ | ✓ | Requires corresponding R support and extra configuration |
RStudio and Positron can be obtained from https://posit.co/downloads/; Visual Studio Code can be obtained from https://code.visualstudio.com/Download.
Once ivdtools has been released on the CRAN mirror you use:
install.packages(c("ivdtools", "rmarkdown", "knitr"))Additional packages can be installed as needed for data import:
install.packages(c("readr", "readxl"))In RStudio, choose File > New File > R Markdown.

Minimal document template:
---
title: "IVD Analysis Report"
author: "Analyst"
date: "Enter the report date"
output:
html_document:
toc: true
number_sections: true
---Then insert an R code chunk named setup with include=FALSE set, containing the following:
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
library(ivdtools)Base R:
dat <- read.csv(
"data-raw/method-comparison.csv",
stringsAsFactors = FALSE,
check.names = FALSE
)Using readr:
dat <- readr::read_csv(
"data-raw/method-comparison.csv",
show_col_types = FALSE
)dat <- readxl::read_excel(
"data-raw/method-comparison.xlsx",
sheet = "data"
)If the Excel file contains formulas, merged cells, or manual formatting, first confirm that the imported values, column names, and data types match the original sheet.
In a .Rmd, insert an R code chunk and use the button at the top-right of the chunk to run the current chunk, or run all code from top to bottom.

To ensure reproducibility, the final report should be rendered from scratch in a fresh R session, rather than relying on objects already present in the Console.
After reading the result fields described on the help page, you can write out a CSV:
# Example: the actual fields should be confirmed against the help page of the corresponding object
result_table <- mc$regression
saveRDS(result_table, "tables/regression-result.rds")Complex objects are best saved as RDS to preserve their class and attributes; when exchanging with other software, tidy them into flat data frames and export as CSV.
p <- plot(mc, type = "bland_altman")
ggplot2::ggsave(
"figures/bland-altman.png",
plot = p,
width = 7,
height = 5,
dpi = 300
)In RStudio, click Knit, or run:
rmarkdown::render(
"report/analysis.Rmd",
output_format = "html_document",
clean = TRUE
)After the analysis is complete, record the environment information:
sessionInfo()
Recommended for archiving:
.Rmd source file;sessionInfo() environment information;