## Install and Load Packages
if (!'remotes' %in% rownames(installed.packages())) install.packages('remotes')
if (!"rshinystatistics" %in% rownames(installed.packages())) {
  remotes::install_github("geiser/rshinystatistics")
} else if (packageVersion("rshinystatistics") < "{{ rshinystatistics.version }}") {
  remotes::install_github("geiser/rshinystatistics")
}

wants <- c('ggplot2','ggpubr','rshinystatistics','utils')
has <- wants %in% rownames(installed.packages())
if (any(!has)) install.packages(wants[!has])

library(utils)
library(ggpubr)
library(ggplot2)
library(rshinystatistics)
library(knitr)
opts_chunk$set(echo = TRUE)
defaultW <- getOption("warn")
options(warn = -1)

Initial Variables and Data

wid <- "{{ wid }}"
between <- c({{ paste0(paste0('"', between, '"'), collapse = ',') }})
dvs <- c({{ paste0(paste0('"',dvs,'"="',dvs,'"'), collapse = ',') }})

dat <- lapply(dvs, FUN = function(dv) {
  data <- read.csv(paste0("../data/table-for-",dv,".csv"))
  rownames(data) <- data[["{{ wid }}"]]
  return(data)
})
rdat <- dat

Descriptive statistics of initial data

(df <- get.descriptives(dat, dvs, between, include.global = T, symmetry.test = T))
kable(df, digits = 3)
{{
sformula <- paste0(paste0('`',between,'`'), collapse = '*')
box.plot.code  <- paste0(lapply(dvs, FUN = function(dv) {
  paste0("car::Boxplot(`",dv,"` ~ ",sformula,", data = dat[[\"",dv,"\"]], id = list(n = Inf))")
}), collapse = '\n')
box.plot.code
}}

Performing Treatment of Symmetry and Outliers

{{ code.skewness }}

{{ code.outliers }}

sdat <- rdat

Saving the Data Without Outliers and Accomplish Symmetry (data for the nonparametric test)

ndat <- sdat[[1]]
for (dv in names(sdat)[-1]) ndat <- merge(ndat, sdat[[dv]])
write.csv(ndat, paste0("../data/table-without-outliers.csv"))

Descriptive statistics of data used in the nonparametric test

(df <- get.descriptives(sdat, dvs, between))
kable(df, digits = 3)
{{
sformula <- paste0(paste0('`',between,'`'), collapse = '*')
box.plot.code  <- paste0(lapply(dvs, FUN = function(dv) {
  paste0("car::Boxplot(`",dv,"` ~ ",sformula,", data = sdat[[\"",dv,"\"]], id = list(n = Inf))")
}), collapse = '\n')
box.plot.code
}}

Computation of Hypothesis Test and Pairwise Comparison

{{ title.test }}

{{ code.hypothesis }}

{{ code.hypothesis.tbl }}

{{ code.pwc }}

{{ code.pwc.tbl }}

{{ code.plots }}

Textual Report

{{ hypothesis.text }}

{{ hypothesis.pwc.text }}

Tips and References



geiser/rshinystatistics documentation built on Feb. 18, 2024, 6:07 p.m.