Description Usage Arguments Details Examples
add_stats
adds output to a tidystats list. It can take either the
output of a statistical test as input or a data frame. See Details for more
information on adding data frames.
1 2 |
results |
A tidystats list. |
output |
Output of a statistical test or a data frame. If a data frame is provided, it must already be in a tidy format. |
identifier |
A character string identifying the model. Automatically created if not provided. |
type |
A character string indicating the type of test. One of "hypothesis", "manipulation check", "contrast", "descriptives", or "other". Can be abbreviated. |
confirmatory |
A boolean to indicate whether the statistical test was confirmatory (TRUE) or exploratory (FALSE). Can be NA. |
notes |
A character string to add additional information. Some statistical tests produce notes information, which will be overwritten if notes are provided. |
class |
A character string to indicate which function was used to produce the output. See 'Details' for a list of supported functions. |
args |
An optional list of additional arguments. Can be used to specify how model results should be summarized. |
Some statistical functions produce unidentifiable output, which
means tidystats
cannot figure out how to tidy the data. To add these
results, you can provide a class via the class argument or you can manually
tidy the results yourself and add the resulting data frame via add_stats().
A list of supported classes are:
- confint
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | # Create an empty list to store the results in
results <- list()
# Example: t-test
model_t_test <- t.test(extra ~ group, data = sleep)
results <- add_stats(results, model_t_test, identifier = "t_test")
# Example: correlation
x <- c(44.4, 45.9, 41.9, 53.3, 44.7, 44.1, 50.7, 45.2, 60.1)
y <- c( 2.6, 3.1, 2.5, 5.0, 3.6, 4.0, 5.2, 2.8, 3.8)
model_correlation <- cor.test(x, y)
# Add output to the results list, only storing the correlation and p-value
results <- add_stats(results, model_correlation, identifier = "correlation")
# Example: Regression
ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group <- gl(2, 10, 20, labels = c("Ctl","Trt"))
weight <- c(ctl, trt)
model_lm <- lm(weight ~ group)
# Add output to the results list, with notes
results <- add_stats(results, model_lm, identifier = "regression", notes =
"regression example")
# Example: ANOVA
model_aov <- aov(yield ~ block + N * P * K, npk)
results <- add_stats(results, model_aov, identifier = "ANOVA")
# Example: Within-subjects ANOVA
model_aov_within <- aov(extra ~ group + Error(ID/group), data = sleep)
results <- add_stats(results, model_aov_within, identifier = "ANOVA_within")
# Example: Manual chi-squared test of independence
library(tibble)
x_squared_data <- tibble(
statistic = c("X-squared", "df", "p"),
value = c(5.4885, 6, 0.4828),
method = "Chi-squared test of independence"
)
results <- add_stats(results, x_squared_data, identifier = "x_squared")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.