# LIBRARIES
suppressPackageStartupMessages({library(dplyr)
library(ggplot2)
library(purrr)
library(readr)})
# DATA
read_csv("/home/roc/Desktop/grist.csv") -> dat
#> Parsed with column specification:
#> cols(
#> HarvTMT = col_character(),
#> FrondCount = col_double(),
#> Wt = col_double(),
#> MaxHt = col_double(),
#> MeanHt = col_double(),
#> SDHt = col_double(),
#> Girth = col_double(),
#> SA = col_double(),
#> FD = col_double(),
#> MeanOpen = col_double(),
#> SDOpen = col_double(),
#> OpenCount = col_double()
#> )
#> Warning: 1 parsing failure.
#> row col expected actual file
#> 19 -- 12 columns 7 columns '/home/roc/Desktop/grist.csv'
# PREPROCCESSING
# use rm_na(dat) -> dat, if desired
# CONSTANTS
the_vars <- colnames(dat)[2:length(dat)]
# FUNCTIONS
# eyeball reasonableness of distribution assumption
# use interactively
mk_plot <- function(x) {
p <- ggplot(dat)
p + geom_density(aes(x, fill = HarvTMT),
position = "identity", alpha = 0.5) +
labs(x = enquo(x), y = 'Density') +
scale_fill_discrete(name = 'Treatment') +
theme_minimal()
}
# map over the_vars
mk_aov <- function() {
dat[the_vars] %>% map(~ aov(. ~ dat$HarvTMT))
}
# remove NAs
rm_na <- function(x) {
x <- x[complete.cases(x),]
}
# test balance
test_bal <- function(x) {
!is.list(replications(~ x - as.factor(HarvTMT), dat))
}
# MAIN
# Example interactive plot
mk_plot(dat$FrondCount)

# map over the_vars to stdout
mk_aov()
#> $FrondCount
#> Call:
#> aov(formula = . ~ dat$HarvTMT)
#>
#> Terms:
#> dat$HarvTMT Residuals
#> Sum of Squares 32114.64 27233.04
#> Deg. of Freedom 3 15
#>
#> Residual standard error: 42.60911
#> Estimated effects may be unbalanced
#>
#> $Wt
#> Call:
#> aov(formula = . ~ dat$HarvTMT)
#>
#> Terms:
#> dat$HarvTMT Residuals
#> Sum of Squares 44679318 142793779
#> Deg. of Freedom 3 15
#>
#> Residual standard error: 3085.383
#> Estimated effects may be unbalanced
#>
#> $MaxHt
#> Call:
#> aov(formula = . ~ dat$HarvTMT)
#>
#> Terms:
#> dat$HarvTMT Residuals
#> Sum of Squares 13476.07 29081.54
#> Deg. of Freedom 3 14
#>
#> Residual standard error: 45.57689
#> Estimated effects may be unbalanced
#> 1 observation deleted due to missingness
#>
#> $MeanHt
#> Call:
#> aov(formula = . ~ dat$HarvTMT)
#>
#> Terms:
#> dat$HarvTMT Residuals
#> Sum of Squares 621.3159 2467.3116
#> Deg. of Freedom 3 15
#>
#> Residual standard error: 12.82527
#> Estimated effects may be unbalanced
#>
#> $SDHt
#> Call:
#> aov(formula = . ~ dat$HarvTMT)
#>
#> Terms:
#> dat$HarvTMT Residuals
#> Sum of Squares 423.081 1899.687
#> Deg. of Freedom 3 15
#>
#> Residual standard error: 11.2537
#> Estimated effects may be unbalanced
#>
#> $Girth
#> Call:
#> aov(formula = . ~ dat$HarvTMT)
#>
#> Terms:
#> dat$HarvTMT Residuals
#> Sum of Squares 152.0847 2113.7976
#> Deg. of Freedom 3 13
#>
#> Residual standard error: 12.75146
#> Estimated effects may be unbalanced
#> 2 observations deleted due to missingness
#>
#> $SA
#> Call:
#> aov(formula = . ~ dat$HarvTMT)
#>
#> Terms:
#> dat$HarvTMT Residuals
#> Sum of Squares 338043.8 796718.7
#> Deg. of Freedom 3 13
#>
#> Residual standard error: 247.5602
#> Estimated effects may be unbalanced
#> 2 observations deleted due to missingness
#>
#> $FD
#> Call:
#> aov(formula = . ~ dat$HarvTMT)
#>
#> Terms:
#> dat$HarvTMT Residuals
#> Sum of Squares 0.04038058 0.09870342
#> Deg. of Freedom 3 13
#>
#> Residual standard error: 0.08713536
#> Estimated effects may be unbalanced
#> 2 observations deleted due to missingness
#>
#> $MeanOpen
#> Call:
#> aov(formula = . ~ dat$HarvTMT)
#>
#> Terms:
#> dat$HarvTMT Residuals
#> Sum of Squares 1.252191 7.557395
#> Deg. of Freedom 3 12
#>
#> Residual standard error: 0.7935886
#> Estimated effects may be unbalanced
#> 3 observations deleted due to missingness
#>
#> $SDOpen
#> Call:
#> aov(formula = . ~ dat$HarvTMT)
#>
#> Terms:
#> dat$HarvTMT Residuals
#> Sum of Squares 38.92192 200.83808
#> Deg. of Freedom 3 12
#>
#> Residual standard error: 4.091028
#> Estimated effects may be unbalanced
#> 3 observations deleted due to missingness
#>
#> $OpenCount
#> Call:
#> aov(formula = . ~ dat$HarvTMT)
#>
#> Terms:
#> dat$HarvTMT Residuals
#> Sum of Squares 8582.167 12501.583
#> Deg. of Freedom 3 12
#>
#> Residual standard error: 32.27691
#> Estimated effects may be unbalanced
#> 3 observations deleted due to missingness
Created on 2020-09-15 by the reprex package (v0.3.0)