Organizing Code With Structured Programming

1.

## Description ----------------------------------
#### description of script: creating fake anova data set, running anova and graphing results.

####  23 Mar 2022
#### GB

## Initialize -----------------------------------
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.5     ✓ purrr   0.3.4
## ✓ tibble  3.1.6     ✓ dplyr   1.0.7
## ✓ tidyr   1.1.4     ✓ stringr 1.4.0
## ✓ readr   2.1.1     ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(ggplot2)

## Load Functions -------------------------------
source("Functions/sim_anova_data.R")  
source("Functions/run_anova.R")  
source("Functions/graph_anova.R") 

## Global Variables -----------------------------

## Program Body ---------------------------------
ano_data <- sim_anova_data()
head(ano_data)
##   ID trt_group proportions
## 1  1   control   0.8830352
## 2  2   control   0.9105646
## 3  3   control   0.7094341
## 4  4   control   0.7199293
## 5  5   control   0.9671908
## 6  6   control   0.7451187
run_anova(dataframe = ano_data)
## Call:
##    aov(formula = proportions ~ trt_group, data = dataframe)
## 
## Terms:
##                 trt_group Residuals
## Sum of Squares   5.871748  1.051952
## Deg. of Freedom         1        88
## 
## Residual standard error: 0.1093343
## Estimated effects may be unbalanced
graph_anova(dataframe = ano_data)

2. Modifying Program:

## Description ----------------------------------
#### description of script: creating fake anova data set, running anova and outputting graph with raw data overlaying boxpolot. 

####  23 Mar 2022
#### GB

## Initialize -----------------------------------
library(tidyverse)
library(ggplot2)

## Load Functions -------------------------------
source("Functions/sim_anova_data.R")  
source("Functions/run_anova.R")  
source("Functions/graph_anova2.R") 

## Global Variables -----------------------------

## Program Body ---------------------------------
data.frame <- sim_anova_data()
head(data.frame)
##   ID trt_group proportions
## 1  1   control   0.9552373
## 2  2   control   0.9032927
## 3  3   control   0.7788333
## 4  4   control   0.7971124
## 5  5   control   0.9347276
## 6  6   control   0.9613197
run_anova(dataframe = data.frame)
## Call:
##    aov(formula = proportions ~ trt_group, data = dataframe)
## 
## Terms:
##                 trt_group Residuals
## Sum of Squares   6.712382  0.968334
## Deg. of Freedom         1        88
## 
## Residual standard error: 0.104899
## Estimated effects may be unbalanced
graph_anova2(dataframe = data.frame)