RootKit is a R package for reusable research-analysis infrastructure and publication plotting conventions. It deliberately separates generic working conventions from project-specific scientific decisions.
RootKit owns:
- standard project scaffolding
- project-relative path helpers
- a reusable ggplot2 publication theme
- fixed physical panel sizing for publication figures
- standard figure/table export
- a very small set of genuinely reusable formatting helpers
Each research project owns:
- experimental factors and factor levels
- project-specific colours and labels
- input-file definitions
- statistical models and contrasts
- project-specific helper functions
project_name/
├── 00_input/
├── 01_code/
├── 02_docs/
├── 03_output/
├── R/
│ ├── config.R
│ ├── utils.R
│ └── init.R
├── .here
└── project_name.Rproj
library(RootKit)
create_project("Proj_01")By default, the new project is created under the current working directory
(getwd()). Project names containing spaces are rejected.
Most projects contain several analysis modules. They can be created together with the project:
create_project(
"Proj_01",
subfolders = c(
"01_data_processing",
"02_statistics",
"03_visualisation"
)
)RootKit then creates matching code and output folders:
01_code/
├── 01_data_processing/
├── 02_statistics/
└── 03_visualisation/
03_output/
├── 01_data_processing/
│ ├── figures/
│ ├── tables/
│ └── objects/
├── 02_statistics/
│ ├── figures/
│ ├── tables/
│ └── objects/
└── 03_visualisation/
├── figures/
├── tables/
└── objects/
Subfolder names follow the same path-safe naming rule as project names: use letters, numbers, underscores, or hyphens and avoid spaces.
paths <- analysis_paths("03_traits_visualization")
paths$figures
paths$tables
paths$objectsThis creates the corresponding structure under 03_output/.
Master files often keep units in column names for readability. RootKit can remove the trailing unit label and standardise the remaining names without touching the data values:
dat <- clean_unit_names(dat)For example:
Shoot biomass (g) -> shoot_biomass
Plant height [cm] -> plant_height
NH4-N (mg kg-1 soil) -> nh4_n
Sample ID -> sample_id
Only the final (...) or [...] block is treated as the unit. If removing
units would create duplicated column names, RootKit stops and reports the
conflict instead of adding automatic suffixes.
p + theme_rootkit()The default base font size is 7 pt. Frequently changing details remain adjustable:
p + theme_rootkit(x_angle = 25, legend_pos = "right")
p + theme_rootkit(panel = "boxed")A later ggplot2::theme() call can always override individual details.
panel_size() controls the size of the data panel itself, excluding axis text,
axis titles, facet strips, legends, and outer margins.
p + panel_size() # 3.5 x 3.5 cm
p + panel_size(3) # 3 x 3 cm
p + panel_size(4.5) # 4.5 x 4.5 cm
p + panel_size(4.5, 3.5) # rectangular panelWhen facets are used, add panel_size() after the facet specification.
A typical single-panel figure therefore looks like:
p <- ggplot2::ggplot(mtcars, ggplot2::aes(wt, mpg)) +
ggplot2::geom_point(size = 1.5) +
theme_rootkit() +
panel_size(3.5)save_figure(
p,
dir = paths$figures,
filename = "example",
width = 8,
height = 6
)save_figure() uses centimetres for total canvas dimensions by default and
exports both vector PDF and 600-dpi PNG. The total canvas size is deliberately
kept separate from panel_size(), because legends and axis decorations vary
between figures.
Install development tools once:
install.packages(c("devtools", "usethis", "roxygen2", "testthat"))Open RootKit.Rproj, then use:
devtools::load_all()
devtools::document()
devtools::test()
devtools::check()
devtools::install()Before the first formal devtools::check(), add the maintainer email to
Authors@R in DESCRIPTION.