| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/emmeans.R |
| 3 |
\name{tidy.ref.grid} |
| 4 |
\alias{tidy.ref.grid} |
| 5 |
\title{Tidy a(n) ref.grid object} |
| 6 |
\usage{ |
| 7 |
\method{tidy}{ref.grid}(x, conf.int = FALSE, conf.level = 0.95, ...) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{x}{A \code{ref.grid} object created by \code{\link[emmeans:ref_grid]{emmeans::ref_grid()}}.} |
| 11 |
|
| 12 |
\item{conf.int}{Logical indicating whether or not to include a confidence |
| 13 |
interval in the tidied output. Defaults to \code{FALSE}.} |
| 14 |
|
| 15 |
\item{conf.level}{The confidence level to use for the confidence interval |
| 16 |
if \code{conf.int = TRUE}. Must be strictly greater than 0 and less than 1. |
| 17 |
Defaults to 0.95, which corresponds to a 95 percent confidence interval.} |
| 18 |
|
| 19 |
\item{...}{Additional arguments passed to \code{\link[emmeans:summary.emmGrid]{emmeans::summary.emmGrid()}} or |
| 20 |
\code{\link[lsmeans:ref.grid]{lsmeans::summary.ref.grid()}}. \strong{Cautionary note}: misspecified arguments |
| 21 |
may be silently ignored!} |
| 22 |
} |
| 23 |
\description{ |
| 24 |
Tidy summarizes information about the components of a model. |
| 25 |
A model component might be a single term in a regression, a single |
| 26 |
hypothesis, a cluster, or a class. Exactly what tidy considers to be a |
| 27 |
model component varies across models but is usually self-evident. |
| 28 |
If a model has several distinct types of components, you will need to |
| 29 |
specify which components to return. |
| 30 |
} |
| 31 |
\details{ |
| 32 |
Returns a data frame with one observation for each estimated marginal |
| 33 |
mean, and one column for each combination of factors. When the input is a |
| 34 |
contrast, each row will contain one estimated contrast. |
| 35 |
|
| 36 |
There are a large number of arguments that can be |
| 37 |
passed on to \code{\link[emmeans:summary.emmGrid]{emmeans::summary.emmGrid()}} or \code{\link[lsmeans:ref.grid]{lsmeans::summary.ref.grid()}}. |
| 38 |
} |
| 39 |
\examples{ |
| 40 |
\dontshow{if (rlang::is_installed(c("emmeans", "ggplot2"))) withAutoprint(\{ # examplesIf} |
| 41 |
|
| 42 |
# load libraries for models and data |
| 43 |
library(emmeans) |
| 44 |
|
| 45 |
# linear model for sales of oranges per day |
| 46 |
oranges_lm1 <- lm(sales1 ~ price1 + price2 + day + store, data = oranges) |
| 47 |
|
| 48 |
# reference grid; see vignette("basics", package = "emmeans") |
| 49 |
oranges_rg1 <- ref_grid(oranges_lm1) |
| 50 |
td <- tidy(oranges_rg1) |
| 51 |
td |
| 52 |
|
| 53 |
# marginal averages |
| 54 |
marginal <- emmeans(oranges_rg1, "day") |
| 55 |
tidy(marginal) |
| 56 |
|
| 57 |
# contrasts |
| 58 |
tidy(contrast(marginal)) |
| 59 |
tidy(contrast(marginal, method = "pairwise")) |
| 60 |
|
| 61 |
# plot confidence intervals |
| 62 |
library(ggplot2) |
| 63 |
|
| 64 |
ggplot(tidy(marginal, conf.int = TRUE), aes(day, estimate)) + |
| 65 |
geom_point() + |
| 66 |
geom_errorbar(aes(ymin = conf.low, ymax = conf.high)) |
| 67 |
|
| 68 |
# by multiple prices |
| 69 |
by_price <- emmeans(oranges_lm1, "day", |
| 70 |
by = "price2", |
| 71 |
at = list( |
| 72 |
price1 = 50, price2 = c(40, 60, 80), |
| 73 |
day = c("2", "3", "4") |
| 74 |
) |
| 75 |
) |
| 76 |
|
| 77 |
by_price |
| 78 |
|
| 79 |
tidy(by_price) |
| 80 |
|
| 81 |
ggplot(tidy(by_price, conf.int = TRUE), aes(price2, estimate, color = day)) + |
| 82 |
geom_line() + |
| 83 |
geom_errorbar(aes(ymin = conf.low, ymax = conf.high)) |
| 84 |
|
| 85 |
# joint_tests |
| 86 |
tidy(joint_tests(oranges_lm1)) |
| 87 |
\dontshow{\}) # examplesIf} |
| 88 |
} |
| 89 |
\seealso{ |
| 90 |
\code{\link[=tidy]{tidy()}}, \code{\link[emmeans:ref_grid]{emmeans::ref_grid()}}, \code{\link[emmeans:emmeans]{emmeans::emmeans()}}, |
| 91 |
\code{\link[emmeans:contrast]{emmeans::contrast()}} |
| 92 |
|
| 93 |
Other emmeans tidiers: |
| 94 |
\code{\link{tidy.emmGrid}()}, |
| 95 |
\code{\link{tidy.lsmobj}()}, |
| 96 |
\code{\link{tidy.summary_emm}()} |
| 97 |
} |
| 98 |
\concept{emmeans tidiers} |
| 99 |
\value{ |
| 100 |
A \code{\link[tibble:tibble]{tibble::tibble()}} with columns: |
| 101 |
\item{conf.high}{Upper bound on the confidence interval for the estimate.} |
| 102 |
\item{conf.low}{Lower bound on the confidence interval for the estimate.} |
| 103 |
\item{df}{Degrees of freedom used by this term in the model.} |
| 104 |
\item{p.value}{The two-sided p-value associated with the observed statistic.} |
| 105 |
\item{std.error}{The standard error of the regression term.} |
| 106 |
\item{estimate}{Expected marginal mean} |
| 107 |
\item{statistic}{T-ratio statistic} |
| 108 |
|
| 109 |
} |