Skip to contents

1 Abstract

Results of every analysis can be written as tables for a paper, in Word, LaTeX, HTML, Markdown or CSV, with da_export(); da_tables() gives the same tables as data frames. DiallelApp() runs the analyses in a web browser without writing code. This vignette shows both.

2 The tables of an analysis

fit <-
  Griffing(
      y          = Yield
    , Rep        = Rep
    , Cross1     = Cross1
    , Cross2     = Cross2
    , data       = GriffingData2
    , Method     = 2
    , Model      = 1
    , Reciprocal = c("combined", "split")[1]
    )
tb <-
  da_tables(
      x      = fit
    , digits = 3
    )
names(tb)
[1] "Analysis of variance"               "Components"
[3] "General combining ability effects"  "Specific combining ability effects"
[5] "Standard errors"                   
tb[["Analysis of variance"]]
  Source  Df    Sum Sq Mean Sq F value Pr(>F)
1    gca   7  1850.893 264.413   9.470 <0.001
2    sca  28 12529.107 447.468  16.026 <0.001
3  Error 105  2931.770  27.922               

Each analysis has its own set: Hayman’s analysis gives the analysis of variance, the \(W_r\)-\(V_r\) table and the genetic parameters; the line \(\times\) tester analysis the analysis of variance, the proportional contributions, the effects and the components; and so on.

3 Export to Word, LaTeX, HTML, Markdown or CSV

da_export() writes the tables, all or a chosen few, with a set number of decimal places. A LaTeX file uses the booktabs rules and can be included in a paper with \input{}:

tex <- tempfile(fileext = ".tex")
da_export(
    x      = fit
  , file   = tex
  , format = c("docx", "latex", "html", "markdown", "csv")[2]
  , tables = "Analysis of variance"
  , digits = 2
  , title  = "Combining-ability analysis of variance"
  )
cat(readLines(con = tex), sep = "\n")
% Combining-ability analysis of variance
% tables written by DiallelAnalysisR::da_export(); needs \usepackage{booktabs}

\begin{table}[htbp]
\centering
\caption{Analysis of variance}
\begin{tabular}{lrrrrr}
\toprule
Source & Df & Sum Sq & Mean Sq & F value & Pr(>F) \\
\midrule
gca & 7 & 1850.89 & 264.41 & 9.47 & $<$0.001 \\
sca & 28 & 12529.11 & 447.47 & 16.03 & $<$0.001 \\
Error & 105 & 2931.77 & 27.92 &  &  \\
\bottomrule
\end{tabular}
\end{table}

A Word file (with the suggested packages officer and flextable) has one formatted table per result, each with its title, ready to paste into a manuscript:

docx <- tempfile(fileext = ".docx")
da_export(
    x      = fit
  , file   = docx
  , format = c("docx", "latex", "html", "markdown", "csv")[1]
  , tables = NULL
  , digits = 3
  , title  = NULL
  )
file.exists(docx)
[1] TRUE

Markdown tables suit Quarto and R Markdown documents; CSV writes one file per table for a spreadsheet.

4 The interactive application

DiallelApp(
    launch.browser = TRUE
  )

The application (packages shiny and bslib) has four tabs:

  1. Data: an example data set of the package or a CSV file with one row per plot.
  2. Results: the printed analysis and its tables. The sidebar sets the analysis (Griffing, Griffing over environments, heterosis, Hayman, Gardner and Eberhart, partial diallel, line \(\times\) tester, North Carolina designs), the columns of the response, replicates and parents, and the options of the analysis.
  3. Plots: every plot of the analysis.
  4. Export: the tables in Word, LaTeX, HTML or Markdown, and the R code that repeats the analysis in a script, in the style of the examples of this package.

The application with Griffing’s Method 2 analysis of GriffingData2.

5 Summary

da_tables() and da_export() turn any result into tables for a report; DiallelApp() gives the same analyses and tables without code, and shows the code for later use.