inline_stats: In-line stats

inline_statsR Documentation

In-line stats

Description

Convenience functions to summarize statistical tests.

Usage

inl_anova(x, y = NULL, ..., details = TRUE, digits = 2L)

inl_ca(x, y = NULL, ..., details = TRUE, digits = 2L)

inl_chisq(x, y = NULL, ..., details = TRUE, digits = 2L)

inl_cuzick(x, y = NULL, ..., details = TRUE, digits = 2L)

inl_fisher(x, y = NULL, ..., details = TRUE, digits = 2L)

inl_jt(x, y = NULL, ..., details = TRUE, digits = 2L)

inl_kruskal(x, y = NULL, ..., details = TRUE, digits = 2L)

inl_kw(x, y = NULL, ..., details = TRUE, digits = 2L)

inl_logrank(object, ..., details = TRUE, digits = 2L)

inl_t(x, y = NULL, ..., details = TRUE, digits = 2L)

inl_wilcox(x, y = NULL, ..., details = TRUE, digits = 2L)

Arguments

x

numeric or factor-like variable, table, or a list depending on the statistic

y

(optional) group or stratification variable

...

additional arguments passed to the stat function

details

logical; if FALSE, only the p-value is printed; if TRUE, additional details depending on the test (e.g., the test statistic, degrees of freedom depending, etc.) are printed

digits

number of digits past the decimal point to keep

object

for inl_logrank, a survdiff object or formula to be passed to survdiff

Examples

x <- mtcars$vs
y <- mtcars$am

## t-test (two-sample)
t.test(x ~ y)
inl_t(split(x, y))
inl_t(x, y)

## t-test (paired)
t.test(x, y, paired = TRUE)
inl_t(list(x, y), paired = TRUE)
inl_t(c(x, y), rep(1:2, each = length(x)), paired = TRUE)


## fisher's exact
fisher.test(x, y)
inl_fisher(x, y)
inl_fisher(table(x, y))


## chi-squared test for count data
chisq.test(table(x, y))
inl_chisq(x, y)
inl_chisq(table(x, y))


## wilcoxon rank-sum test
wilcox.test(mtcars$mpg ~ y)
inl_wilcox(mtcars$mpg, y)
inl_wilcox(split(mtcars$mpg, y))

## wilcoxon signed-rank test
wilcox.test(x, y, paired = TRUE)
inl_wilcox(list(x, y), paired = TRUE)
inl_wilcox(c(x, y), rep(1:2, each = length(x)), paired = TRUE)


## cuzick's trend test
cuzick.test(mpg ~ gear, mtcars)
inl_cuzick(mtcars$mpg, mtcars$gear)
inl_cuzick(split(mtcars$mpg, mtcars$gear))


## jonckheere-terpstra test
jt.test(table(mtcars$gear, mtcars$cyl))
inl_jt(mtcars$gear, mtcars$cyl)
inl_jt(table(mtcars$gear, mtcars$cyl))


## cochran-armitage test for trend
ca.test(table(mtcars$vs, mtcars$cyl))
inl_ca(mtcars$vs, mtcars$cyl)
inl_ca(table(mtcars$vs, mtcars$cyl))


## test for trend in proportions
kw.test(table(mtcars$gear, mtcars$cyl))
inl_kw(mtcars$gear, mtcars$cyl)
inl_kw(table(mtcars$gear, mtcars$cyl))


## log-rank test
library('survival')
s1 <- survdiff(Surv(time, status) ~ sex, colon)
s2 <- survdiff(Surv(time, status) ~ sex + strata(age), colon)
inl_logrank(s1)
inl_logrank(s2)
inl_logrank(Surv(time, status) ~ sex, data = colon)


raredd/rawr documentation built on March 4, 2024, 1:36 a.m.