## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(collapse = FALSE, comment = "", fig.width = 7, fig.height = 4.2,
                      dev = if (knitr::is_latex_output()) "cairo_pdf" else
                        if (requireNamespace("svglite", quietly = TRUE)) "svglite" else "png")
if (requireNamespace("DiallelAnalysisR", quietly = TRUE)) library(DiallelAnalysisR) else
  pkgload::load_all(export_all = FALSE, helpers = FALSE, quiet = TRUE)


## ----lt-----------------------------------------------------------------------
lt <-
  LineTester(
      y          = Yield
    , Rep        = Rep
    , Line       = Line
    , Tester     = Tester
    , data       = LineTesterData
    , Inbreeding = 1
    )
lt
round(x = lt$GCA.Lines, digits = 2)
round(x = lt$StdErr, digits = 3)


## ----lt-plot------------------------------------------------------------------
plot(x = lt, which = c("gca", "sca", "contribution", "biplot", "residuals", "qq")[1])


## ----nc-----------------------------------------------------------------------
nc <- lapply(X = 1:3, FUN = function(k) {
  NCDesign(
      y          = Yield
    , Rep        = Rep
    , Male       = Male
    , Female     = Female
    , data       = NCData[NCData$Design == k, ]
    , Design     = k
    , Inbreeding = 0
    )
})
nc[[2]]$ANOVA
round(
    x      = sapply(
        X   = nc
      , FUN = function(z) z$Genetic.Components[c("Additive", "Dominance", "Degree of dominance"),
                                                                       "Components"]
      )
  , digits = 3
  )

