## ----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)


## ----tables-------------------------------------------------------------------
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)
tb[["Analysis of variance"]]


## ----latex--------------------------------------------------------------------
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")


## ----docx, eval = requireNamespace("officer", quietly = TRUE) && requireNamespace("flextable", quietly = TRUE)----
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)


## ----app, eval = FALSE--------------------------------------------------------
# DiallelApp(
#     launch.browser = TRUE
#   )

