How a new analysis is added to DiallelAnalysisR so that it fits the rest of the package: a computational core, an exported function, a result with methods, a help page, tests and a vignette section.
2 The parts of an analysis
Core: an internal function .da_<analysis>_core() that takes the table of cell means (or the plot data) and returns the named list of results; no printing, no options.
Exported function: checks the arguments (.da_check_data(), .da_column() for column arguments, .da_check_number() for codes), calls the core, and wraps the result with .da_result(), which adds the class c("da_<analysis>", "da_result", "list").
Plot: an internal .da_plot_<analysis>(); plot() finds it by the class.
Help page: the model and every formula in LaTeX, every argument, every component of the result, references, examples with every argument written out.
Tests: closed forms against an independent calculation; input errors; methods.
Df Sum Sq Mean Sq
Rep 3 1036.192 345.3972
Crosses 63 104923.873 1665.4583
Residuals 189 21755.963 115.1109
.da_cell_data() gives the table of cell means, the error mean square and its degrees of freedom for any of Griffing’s layouts; a new analysis starts from it.
4 Example: heterosis over the mid-parent
The heterosis of Heterosis() was built from these blocks. Its first step, by hand:
1 2 3 4
1 NA -5.4 13.3 29.7
2 NA NA 29.5 -7.1
3 NA NA NA 21.5
4 NA NA NA NA
The exported function adds the argument checks, the better-parent and standard heterosis, the \(t\) tests with the standard error of each difference from \(MS_E\), a classed result, a plot method, tables for da_export() and tests:
Every analysis of the package follows the same pattern; a new one reuses the cell-means table, the error mean square, the result class, the plot theme and the test helpers.