## ----setup, include=FALSE-----------------------------------------------------
knitr::opts_chunk$set(
  collapse  = TRUE,
  comment   = "#>",
  fig.width = 7,
  fig.height = 4.5,
  out.width = "100%"
)
library(EasyStat)

## ----describe-single----------------------------------------------------------
result <- easy_describe(mtcars$mpg)
print(result, viewer = FALSE)

## ----describe-multi-----------------------------------------------------------
result <- easy_describe(mtcars, vars = c("mpg", "hp", "wt"))
print(result, viewer = FALSE)

## ----group-summary------------------------------------------------------------
result <- easy_group_summary(mpg ~ cyl, data = mtcars)
print(result, viewer = FALSE)

## ----regression---------------------------------------------------------------
result <- easy_regression(mpg ~ wt + hp, data = mtcars)
print(result, viewer = FALSE)

## ----ttest--------------------------------------------------------------------
result <- easy_ttest(mpg ~ am, data = mtcars)
print(result, viewer = FALSE)

## ----anova--------------------------------------------------------------------
result <- easy_anova(Sepal.Length ~ Species, data = iris)
print(result, viewer = FALSE)

## ----chisq--------------------------------------------------------------------
result <- easy_chisq(~ cyl + am, data = mtcars)
print(result, viewer = FALSE)

## ----ftest--------------------------------------------------------------------
result <- easy_ftest(mpg ~ am, data = mtcars)
print(result, viewer = FALSE)

## ----correlation--------------------------------------------------------------
result <- easy_correlation(~ mpg + wt, data = mtcars)
print(result, viewer = FALSE)

## ----corr-matrix--------------------------------------------------------------
result <- easy_correlation(mtcars, vars = c("mpg", "hp", "wt", "disp"))
print(result, viewer = FALSE)

## ----histogram----------------------------------------------------------------
p <- easy_histogram("mpg", data = mtcars)
p$plot_object

## ----boxplot------------------------------------------------------------------
p <- easy_boxplot(Sepal.Length ~ Species, data = iris)
p$plot_object

## ----scatter------------------------------------------------------------------
p <- easy_scatter(mpg ~ wt, data = mtcars)
p$plot_object

## ----barplot------------------------------------------------------------------
p <- easy_barplot("mpg", data = mtcars, group_by = "cyl", stat = "mean")
p$plot_object

## ----qqplot-------------------------------------------------------------------
p <- easy_qqplot("mpg", data = mtcars)
p$plot_object

## ----density------------------------------------------------------------------
p <- easy_density("Sepal.Length", data = iris, group_by = "Species")
p$plot_object

## ----heatmap------------------------------------------------------------------
p <- easy_correlation_heatmap(mtcars, vars = c("mpg", "hp", "wt", "qsec", "drat"))
p$plot_object

## ----word-export, eval=FALSE--------------------------------------------------
# reg_result <- easy_regression(mpg ~ wt + hp, data = mtcars)
# 
# export_to_word(
#   reg_result,
#   file   = "MyReport.docx",
#   title  = "Fuel Economy Analysis",
#   author = "Mahesh Divakaran, Gunjan Singh, Jayadevan Shreedharan"
# )

## ----fields-------------------------------------------------------------------
result <- easy_ttest(mpg ~ am, data = mtcars)
cat(result$explanation)

