## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>", fig.width = 6.5,
                      fig.height = 4.2, dpi = 120)

## ----setup--------------------------------------------------------------------
library(trialSizing)

## ----data---------------------------------------------------------------------
grid1 <- as.matrix(uniformity_trial[uniformity_trial$trial == "T1",
                                    grep("^col", names(uniformity_trial))])
dim(grid1)

## ----fit----------------------------------------------------------------------
tab <- calc_cv_shapes(grid1)
tab

## ----orientation--------------------------------------------------------------
tab[tab$x == 2, ]

## ----counts-------------------------------------------------------------------
unique(tab[, c("x", "n")])

## ----feed---------------------------------------------------------------------
fit_lrp(tab, x = "x", cv = "cv", step = 0.05)

## ----multi--------------------------------------------------------------------
grids <- lapply(split(uniformity_trial, uniformity_trial$trial),
                function(d) as.matrix(d[, grep("^col", names(d))]))

tab3 <- calc_cv_shapes(grids)
table(tab3$trial)

## ----multi-fit----------------------------------------------------------------
fit_lrp(tab3, x = "x", cv = "cv", trial = "trial", step = 0.05)$summary

## ----long---------------------------------------------------------------------
long <- expand.grid(col = 1:12, row = 1:8)
long$mf <- as.vector(t(grid1))

head(calc_cv_shapes(long, value = "mf", row_id = "row", col_id = "col"), 4)

