## ----include = FALSE------------------------------------------------------------------------------
old_options <- options(width = 100)
knitr::opts_chunk$set(collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 4.4, dpi = 72, out.width = "100%")

## -------------------------------------------------------------------------------------------------
library(AgriDesign)
head(maize_nitrogen)

## -------------------------------------------------------------------------------------------------
fit <- design_anova(maize_nitrogen, response = "Yield_t_ha", treatment = "Nitrogen_kg_ha",
                    block = "Block")
fit

## -------------------------------------------------------------------------------------------------
designs()[, c("id", "name")]

## -------------------------------------------------------------------------------------------------
check_assumptions(fit)

## ----fig.height = 5.5-----------------------------------------------------------------------------
plot(fit)

## -------------------------------------------------------------------------------------------------
tom <- design_anova(tomato_factorial, "Yield_kg_plant", c("Variety", "Fertilizer"), block = "Block")
transformations(tom)$verdict
tom_log <- design_anova(tomato_factorial, "Yield_kg_plant", c("Variety", "Fertilizer"),
                        block = "Block", transform = "log")
check_assumptions(tom_log)$grade

## -------------------------------------------------------------------------------------------------
cmp <- compare_means(fit, "Nitrogen_kg_ha", method = "tukey")
cmp

## -------------------------------------------------------------------------------------------------
tr <- trend(fit, "Nitrogen_kg_ha")
tr

## -------------------------------------------------------------------------------------------------
test_contrasts(fit, "Nitrogen_kg_ha", rbind("control vs fertilised" = c(3, -1, -1, -1),
                                            "120 vs 180" = c(0, 0, 1, -1)))

## -------------------------------------------------------------------------------------------------
plot(cmp)
plot(cmp, style = "box")
plot(tr)

## ----include = FALSE----------------------------------------------------------
options(old_options)

